com.accyourate.utilities.acySecurity.PasswordEncrypter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of utilities Show documentation
Show all versions of utilities Show documentation
Library containing classes and methods for Accyourate applications
package com.accyourate.utilities.acySecurity;
import org.springframework.security.crypto.bcrypt.BCrypt;
/**
* password encrypter
*
*/
public class PasswordEncrypter {
public String HashPassword(String password){
String salt = BCrypt.gensalt();
String hashed_password = BCrypt.hashpw(password, salt);
return hashed_password;
}
/**
* matches
*
* @param rawPassword rawPassword
* @param encodedPassword encodedPassword
* @return {@link boolean}
*/
public boolean matches(String rawPassword, final String encodedPassword) {
if (encodedPassword == null || encodedPassword.length() == 0) {
return false;
}
return BCrypt.checkpw(rawPassword, encodedPassword);
}
}