Created
October 6, 2022 09:38
-
-
Save firaja/26efc640937259941a05e9d518fb3a0e to your computer and use it in GitHub Desktop.
Password4j - migrate from bcrypt to Argon2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String userPassword = "my password"; | |
String oldHash = "$2y$06$pWbj0v7UGWgOp1mXWfCt1OUAibk5luL758NoVndquXnXfH79zFTRG"; | |
BcryptFunction bcrypt = BcryptFunction.getInstanceFromHash(oldHash); | |
Argon2Function argon2 = Argon2Function.getInstance(14, 20, 1, 32, Argon2.ID); | |
HashUpdate update = Password.check(userPassword, oldHash) | |
.andUpdate() | |
.with(bcrypt, argon2); | |
update.isVerified(); // true | |
update.getHash().getResult(); // $argon2id$v=19$m=14,t=20,p=1$$q0HEx1FUKkHo3FEgD6n+bg3fuWYKcPSYYMuKFl79yMI |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment