Skip to content

Instantly share code, notes, and snippets.

@rameshbaskar
Created March 18, 2020 06:00
Show Gist options
  • Save rameshbaskar/0262dca65a618f03c87c857cecfa9457 to your computer and use it in GitHub Desktop.
Save rameshbaskar/0262dca65a618f03c87c857cecfa9457 to your computer and use it in GitHub Desktop.
Java - Cryptography Example
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