Here you can find the source of generateHash(String plaintext)
public static String generateHash(String plaintext)
//package com.java2s; //License from project: Open Source License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String generateHash(String plaintext) { try {/* w ww .j av a 2s . c om*/ StringBuilder hash = new StringBuilder(); MessageDigest sha = MessageDigest.getInstance("SHA-1"); byte[] hashedBytes = sha.digest(plaintext.getBytes()); char[] digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; for (int idx = 0; idx < hashedBytes.length; ++idx) { byte b = hashedBytes[idx]; hash.append(digits[(b & 0xf0) >> 4]); hash.append(digits[b & 0x0f]); } return hash.toString(); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } } }