Here you can find the source of sha1(String str)
public static String sha1(String str) throws Exception
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; public class Main { public static String sha1(String str) throws Exception { MessageDigest sha = MessageDigest.getInstance("SHA"); sha.update(str.getBytes("utf8")); byte[] bytes = sha.digest(); StringBuilder ret = new StringBuilder(bytes.length << 1); for (int i = 0; i < bytes.length; i++) { ret.append(Character.forDigit((bytes[i] >> 4) & 0xf, 16)); ret.append(Character.forDigit(bytes[i] & 0xf, 16)); }// w w w . ja va 2s . com return ret.toString(); } }