Here you can find the source of sha1(String s)
public static String sha1(String s)
//package com.java2s; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String sha1(String s) { try {//from ww w . ja v a 2s . c o m MessageDigest digest = MessageDigest.getInstance("SHA-1"); digest.update(s.getBytes()); byte messageDigest[] = digest.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < messageDigest.length; i++) { hexString.append(Integer.toHexString((0xFF & messageDigest[i]) | 0x100).substring(1)); } return hexString.toString(); } catch (NoSuchAlgorithmException e) { return ""; } } }