List of usage examples for org.apache.shiro.crypto.hash.format HashFormat format
String format(Hash hash);
From source file:com.meltmedia.cadmium.cli.AuthCommand.java
License:Apache License
/** * Hashes a password the shiro way./*from w w w . j av a2 s . 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); }
From source file:org.obiba.shiro.tools.hasher.Hasher.java
License:Open Source License
public static String hash(String value) { Hash hash = new SimpleHash(DEFAULT_PASSWORD_ALGORITHM_NAME, value, getSalt(), DEFAULT_PASSWORD_NUM_ITERATIONS); HashFormat format = HASH_FORMAT_FACTORY.getInstance(Shiro1CryptFormat.class.getName()); return format.format(hash); }