Closed benkuly closed 2 years ago
val password = "password".encodeToByteArray() val salt = ByteArray(12) { (it + 1).toByte() } val iterationCount = 4096 val keyLength = 256 assertEquals( PBKDF2.pbkdf2WithHmacSHA512(password, salt, iterationCount, keyLength).hex, "77fec6ca97e3c15022b1c51a37cf05739e6a3c90b8c85518427ac5be6f8fa06d" )
Works on equivalent JVM and JS (Browser/NodeJS) implementations, but krypto returns b7cc084e1be412df5352f6f49c6a7b901daa338e7f53f8b873e612134180eac8
b7cc084e1be412df5352f6f49c6a7b901daa338e7f53f8b873e612134180eac8
JVM implementation:
val password = "password" val salt = ByteArray(12) { (it + 1).toByte() } val iterationCount = 4096 val keyLength = 256 val skf: SecretKeyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA512") skf.generateSecret( PBEKeySpec(password.toCharArray(), salt, iterationCount, keyLength) ).encoded
Thank you!
Works on equivalent JVM and JS (Browser/NodeJS) implementations, but krypto returns
b7cc084e1be412df5352f6f49c6a7b901daa338e7f53f8b873e612134180eac8
JVM implementation: