Example usage for org.apache.shiro.crypto.hash.format DefaultHashFormatFactory DefaultHashFormatFactory

List of usage examples for org.apache.shiro.crypto.hash.format DefaultHashFormatFactory DefaultHashFormatFactory

Introduction

In this page you can find the example usage for org.apache.shiro.crypto.hash.format DefaultHashFormatFactory DefaultHashFormatFactory.

Prototype

public DefaultHashFormatFactory() 

Source Link

Usage

From source file:com.masslink.idea.zigbee.shiro.UserPasswordService.java

License:Apache License

public UserPasswordService() {
    this.hashFormatWarned = false;
    DefaultHashService defaultHashService = new DefaultHashService();
    defaultHashService.setHashAlgorithmName(ALGORITHM);
    defaultHashService.setHashIterations(ITERATIONS);
    defaultHashService.setGeneratePublicSalt(true); //always want generated salts for user passwords to be most secure
    defaultHashService.setPrivateSalt(new SimpleByteSource(SALT));
    this.hashService = defaultHashService;
    this.hashFormat = new Shiro1CryptFormat();
    this.hashFormatFactory = new DefaultHashFormatFactory();
}

From source file:com.meltmedia.cadmium.cli.AuthCommand.java

License:Apache License

/**
 * Hashes a password the shiro way.//from   w  ww. jav  a  2s  .c o m
 * @return
 */
private String hashPasswordForShiro() {
    //Hash password
    HashFormatFactory HASH_FORMAT_FACTORY = new DefaultHashFormatFactory();
    SecureRandomNumberGenerator generator = new SecureRandomNumberGenerator();
    int byteSize = 128 / 8;
    ByteSource salt = generator.nextBytes(byteSize);

    SimpleHash hash = new SimpleHash("SHA-256", password, salt, 10);

    HashFormat format = HASH_FORMAT_FACTORY.getInstance("shiro1");
    return format.format(hash);
}