All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.accyourate.utilities.acySecurity.PasswordEncrypter Maven / Gradle / Ivy

There is a newer version: 1.3.3
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy