package com.stylefeng.guns.modular.system.util;
|
|
import org.mindrot.jbcrypt.BCrypt;
|
|
public class PasswordUtils {
|
|
public static String hashPassword(String password) {
|
return BCrypt.hashpw(password, BCrypt.gensalt());
|
}
|
|
public static boolean checkPassword(String password, String hashedPassword) {
|
return BCrypt.checkpw(password, hashedPassword);
|
}
|
|
public static void main(String[] args) {
|
String password = "myPassword";
|
String hashedPassword = hashPassword(password);
|
System.out.println("Hashed Password: " + hashedPassword);
|
|
boolean isPasswordCorrect = checkPassword(password, hashedPassword);
|
System.out.println("Is Password Correct? " + isPasswordCorrect);
|
}
|
}
|