List of usage examples for org.apache.shiro.crypto.hash.format HashFormatFactory getInstance
HashFormat getInstance(String token);
From source file:com.meltmedia.cadmium.cli.AuthCommand.java
License:Apache License
/** * Hashes a password the shiro way.//w w w .ja v a2s . 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); }