Here you can find the source of sha1(String s)
public static String sha1(String s)
//package com.java2s; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String sha1(String s) { return hash(s, "SHA1"); }/* w w w . ja va2s .c o m*/ private static String hash(String s, String algorithm) { String result = s; try { MessageDigest digest = MessageDigest.getInstance(algorithm); byte[] bytes = digest.digest(s.getBytes()); BigInteger biggie = new BigInteger(1, bytes); result = String .format("%0" + (bytes.length << 1) + "x", biggie); } catch (NoSuchAlgorithmException e) { // No way... } return result; } }