相关疑难解决方法(0)

如何在Java中使用sha256散列一些字符串?

如何在Java中使用sha256散列一些字符串?有人知道这个免费图书馆吗?

java cryptography sha256 cryptographic-hash-function

187
推荐指数
11
解决办法
30万
查看次数

如何解密SHA-256加密字符串?

我有一个使用以下方法编码的字符串,有没有办法将此字符串解码回原始值?谢谢.

public synchronized String encode(String password)
        throws NoSuchAlgorithmException, IOException {

    String encodedPassword = null;
    byte[] salt = base64ToByte(saltChars);

    MessageDigest digest = MessageDigest.getInstance("SHA-256");
    digest.reset();
    digest.update(salt);

    byte[] btPass = digest.digest(password.getBytes("UTF-8"));
    for (int i = 0; i < ITERATION_COUNT; i++) {
        digest.reset();
        btPass = digest.digest(btPass);
    }

    encodedPassword = byteToBase64(btPass);     
    return encodedPassword;
}

private byte[] base64ToByte(String str) throws IOException {

    BASE64Decoder decoder = new BASE64Decoder();
    byte[] returnbyteArray = decoder.decodeBuffer(str);

    return returnbyteArray;
}

private String byteToBase64(byte[] bt) {

    BASE64Encoder endecoder = new BASE64Encoder();
    String returnString …
Run Code Online (Sandbox Code Playgroud)

java hash cryptography

47
推荐指数
4
解决办法
23万
查看次数