Here you can find the source of sha1Hash(String toHash)
public static String sha1Hash(String toHash) throws NoSuchAlgorithmException
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String sha1Hash(String toHash) throws NoSuchAlgorithmException { byte[] uniqueKey = toHash.getBytes(); byte[] hash = null; hash = MessageDigest.getInstance("SHA1").digest(uniqueKey); StringBuilder hashString = new StringBuilder(); for (int i = 0; i < hash.length; i++) { String hex = Integer.toHexString(hash[i]); if (hex.length() == 1) { hashString.append('0'); hashString.append(hex.charAt(hex.length() - 1)); } else hashString.append(hex.substring(hex.length() - 2)); }/*from w w w .j ava 2 s .com*/ return hashString.toString(); } }