Java Code Examples for org.springside.modules.security.utils.Digests#generateSalt()

The following examples show how to use org.springside.modules.security.utils.Digests#generateSalt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccountService.java    From spring-boot-quickstart with Apache License 2.0 5 votes vote down vote up
/**
 * 设定安全的密码,生成随机的salt并经过1024次 sha-1 hash
 */
private void entryptPassword(User user) {
    byte[] salt = Digests.generateSalt(SALT_SIZE);
    user.setSalt(Encodes.encodeHex(salt));

    byte[] hashPassword = Digests.sha1(user.getPlainPassword().getBytes(), salt, HASH_INTERATIONS);
    user.setPassword(Encodes.encodeHex(hashPassword));
}
 
Example 2
Source File: AccountService.java    From Mario with Apache License 2.0 5 votes vote down vote up
/**
 * 设定安全的密码,生成随机的salt并经过1024次 sha-1 hash
 */
private void entryptPassword(User user) {
    byte[] salt = Digests.generateSalt(SALT_SIZE);
    user.setSalt(Encodes.encodeHex(salt));

    byte[] hashPassword = Digests.sha1(user.getPlainPassword().getBytes(), salt,
            HASH_INTERATIONS);
    user.setPassword(Encodes.encodeHex(hashPassword));
}
 
Example 3
Source File: UserService.java    From dubai with MIT License 5 votes vote down vote up
/**
 * 设定安全的密码,生成随机的salt并经过1024次 sha-1 hash
 */
void entryptPassword(User user, String plainPassword) {
    byte[] salt = Digests.generateSalt(SALT_SIZE);
    user.setSalt(Encodes.encodeHex(salt));

    byte[] hashPassword = Digests.sha1(plainPassword.getBytes(), salt, HASH_INTERATIONS);
    user.setPassword(Encodes.encodeHex(hashPassword));
}