byte[] salt = createRandomSalt();
try {
md = MessageDigest.getInstance("SHA"); //step 2
} catch (NoSuchAlgorithmException e) {
throw new SystemUnavailableException(e.getMessage());
}
try {
md.update(salt);
md.update(plaintext.getBytes("UTF-8")); //step 3
} catch (UnsupportedEncodingException e) {
throw new SystemUnavailableException(e.getMessage());
}
byte[] raw = md.digest(); //step 4
String hash = "{SSHA}" + (new String(Base64.encodeBase64(concatenate(raw, salt)))); //step 5
return hash; //step 6
}