BCrypt加密解密工具类方法
直接上代码
package com.loit.park.common.utils;
import org.springframework.security.crypto.bcrypt.BCrypt;
/**
* @author hanjinqun
* @date 2023/5/13
* BCrypt工具类
*/
public class BCryptUtils {
/**
* 加密
*/
public static String hashpw(String str) {
return BCrypt.hashpw(str, BCrypt.gensalt());
}
/**
* 校验
*/
public static Boolean checkpw(String password, String hashpw) {
return BCrypt.checkpw(password, hashpw);
}
public static void main(String[] args) {
System.out.println(hashpw("123"));
System.out.println(checkpw("123", "$2a$10$aFsOFzujtPCnUCUKcozsHux0rQ/3faAHGFSVb9Y.B1ntpmEhjRtru"));
}
}
每一天都有新日光,每个人都有新期望。------酷酷的韩