Here you can find the source of sha1(String str)
public static String sha1(String str)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String sha1(String str) { try {/*from w ww . j a v a2s .c om*/ MessageDigest md = MessageDigest.getInstance("SHA-1"); byte[] bytes = md.digest(str.getBytes("utf-8")); StringBuilder sb = new StringBuilder(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { sb.append(String.format("%02x", bytes[i])); } return sb.toString(); } catch (NoSuchAlgorithmException e) { throw new InternalError(); } catch (UnsupportedEncodingException e) { throw new InternalError(); } } }