List of usage examples for org.apache.shiro.codec Base64 encode
public static byte[] encode(byte[] pArray)
From source file:org.archone.ad.ldap.PasswordUtil.java
public static String hashPassword(String password) throws NoSuchAlgorithmException, UnsupportedEncodingException { MessageDigest algorithm = MessageDigest.getInstance("SHA"); byte[] salt = new byte[8]; new Random().nextBytes(salt); algorithm.update(password.getBytes()); algorithm.update(salt);//from w ww . java 2s. co m byte[] hash = algorithm.digest(); return "{SSHA}" + new String(Base64.encode(ArrayUtils.addAll(hash, salt))); }