Created
March 18, 2020 06:00
-
-
Save rameshbaskar/0262dca65a618f03c87c857cecfa9457 to your computer and use it in GitHub Desktop.
Java - Cryptography Example
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
| import static org.springframework.security.crypto.bcrypt.BCrypt.hashpw; | |
| import static org.springframework.security.crypto.bcrypt.BCrypt.gensalt; | |
| import static org.springframework.security.crypto.bcrypt.BCrypt.checkpw; | |
| public class CryptoTest { | |
| public static void main(String[] args) { | |
| String plainText = "Password123"; | |
| String hash = hashpw(plainText, gensalt(12)); | |
| if (checkpw(plainText, hash)) { | |
| System.out.println("Hashing verified."); | |
| } else { | |
| System.err.println("Hashing failed !"); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment