1

Estoy intentando llegar al mismo resultado con un hash para contraseña que utiliza pbkdf2withhmacsha1

en java tengo el siguiente codigo

 public static void main(String[] args) throws NoSuchAlgorithmException, InvalidKeySpecException, UnsupportedEncodingException {
        final int ITERATIONS = 1000;
        final int HASH_SIZE = 24;
        final String s = "123abc";
        final String salt = "FF3BFFD6E104F12B6A406744145E6FB54E0674C61888A192";
       
        PBEKeySpec spec = new PBEKeySpec(s.toCharArray(), DatatypeConverter.parseHexBinary(salt), ITERATIONS, 48);
        SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
        
        String result = DatatypeConverter.printHexBinary(factory.generateSecret(spec).getEncoded());
        
        
        System.out.println(HASH_SIZE * Byte.SIZE);
        System.out.println(result);
    }

y me arroja de resultado

FA1AE4DECD3E52345E8A840FB8E38723505CC04EAA2CE826

en python tengo el siguiente codigo

> 
    from hashlib import pbkdf2_hmac
from binascii import hexlify

key = pbkdf2_hmac(
    hash_name = 'sha1',
    password = b'123abc',
    salt = b'FF3BFFD6E104F12B6A406744145E6FB54E0674C61888A192',
    iterations = 1000,
    dklen = 24
)

print(key.hex())

y me arroja de resultado

bd68c7b9d53adf9cf72805db293a4b3bd7c0d1d0e1b19a0f

Que estoy haciendo mal para que me de el mismo resultado en ambas, tomando como base el codigo de java que es el que esta guardado en la BD

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.