BcryptUtil.java
556 Bytes
package com.bckefu.uccc.bcrypt;
import com.bckefu.uccc.sha.ShaUtil;
import org.springframework.security.crypto.bcrypt.BCrypt;
/**
* Created by caoliang on 2017/8/4.
*/
public class BcryptUtil {
int ROUNDS = 4;
/**
*
* @param content
* @return
*/
public String encrypt(String content){
return BCrypt.hashpw(ShaUtil.shaByApache(content), BCrypt.gensalt(ROUNDS));
}
public boolean checkPwd(String plaintext, String hashed){
return BCrypt.checkpw(ShaUtil.shaByApache(plaintext) , hashed);
}
}