是否可以恢复 PBKDF2 哈希密码?

Cha*_*dup 0 java encryption

仅使用类PBEKeySpec和,并知道和是否有办法解密以恢复?SecretFactorysaltcodedcodedpassword

public static byte[] encodePassword(char[] password, byte[] salt) {
    PBEKeySpec spec = new PBEKeySpec(password, salt, ITERATIONS, KEY_LENGTH);
    Arrays.fill(password, Character.MIN_VALUE);
    try {
        SecretKeyFactory skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
        byte[] coded = skf.generateSecret(spec).getEncoded();
        return coded;
    } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
        throw new AssertionError("Error while hashing a password: " + e.getMessage(), e);
    } finally {
        spec.clearPassword();
    }
}
Run Code Online (Sandbox Code Playgroud)

Mar*_*eel 5

不,无法通过 PBKDF2 等密码哈希算法恢复密码。它不可逆的事实是使用这种算法的主要原因之一。