Here you can find the source of sha1(String str)
public static String sha1(String str)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; public class Main { private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static String sha1(String str) { MessageDigest md;/*from ww w .ja va 2 s.co m*/ try { md = MessageDigest.getInstance("sha1"); md.update(str.getBytes()); byte[] hash = md.digest(); return toHexString(hash); } catch (Exception e) { e.printStackTrace(); return null; } } public static String toHexString(byte[] bytes) { int len = bytes.length; StringBuilder buf = new StringBuilder(len * 2); for (int j = 0; j < len; j++) { buf.append(HEX_DIGITS[(bytes[j] >> 4) & 0x0f]); buf.append(HEX_DIGITS[bytes[j] & 0x0f]); } return buf.toString(); } }