Here you can find the source of SHA1(String str)
@SuppressWarnings("resource") public static String SHA1(String str) throws NoSuchAlgorithmException, UnsupportedEncodingException
//package com.java2s; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Formatter; public class Main { @SuppressWarnings("resource") public static String SHA1(String str) throws NoSuchAlgorithmException, UnsupportedEncodingException { MessageDigest mDigest = MessageDigest.getInstance("SHA-1"); mDigest.reset();/*w ww . j a va2 s .c o m*/ mDigest.update(str.getBytes("UTF-8")); Formatter f = new Formatter(); for (byte b : mDigest.digest()) f.format("%02x", b); return f.toString(); } }