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 { public static String sha1(String str) { try {// w w w. j a v a 2 s. com MessageDigest md = MessageDigest.getInstance("SHA-1"); md.update(str.getBytes()); byte[] b = md.digest(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < b.length; i++) { int v = (int) b[i]; v = v < 0 ? 0x100 + v : v; String cc = Integer.toHexString(v); if (cc.length() == 1) sb.append('0'); sb.append(cc); } return sb.toString(); } catch (Exception e) { } return ""; } }