Tuesday, 23 June 2015

Password Hashing using BCrpyt - jbcrypt.jar

So we have all used authentication for various applications.
Using Bcrypt you can easily use hashing for passwords and other authentication required for your application Implementation simple example.

Maven Dependancy

 <dependency>
        <groupId>org.mindrot</groupId>
        <artifactId>jbcrypt</artifactId>
        <version>0.3m</version>
    </dependency>

1) You can save your data after using the BCrypt method to hash it.
            String  originalPassword = passwd;
            BCrypt.hashpw(originalPassword, BCrypt.gensalt());

2) You match your password entered by the user on login with the hashed password in your DB.
    BCrypt.checkpw(userEnteredPwd, hashedPwdFromDB);


No comments:

Post a Comment

AWS Certificate Manager - Import Certificate

How to import a certificate. Use Key Store Explorer to open the cert and export keypair in PEM format  This will save a file cert.pem. Make ...