Here you can find the source of sha1Hex(String data)
public static String sha1Hex(String data)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static final char[] DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static String sha1Hex(String data) { if (data == null) { throw new IllegalArgumentException("data must not be null"); }/*from w ww . ja va2s .c om*/ byte[] bytes = digest("SHA1", data); return toHexString(bytes); } private static byte[] digest(String algorithm, String data) { MessageDigest digest; try { digest = MessageDigest.getInstance(algorithm); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } return digest.digest(data.getBytes()); } private static String toHexString(byte[] bytes) { int l = bytes.length; char[] out = new char[l << 1]; for (int i = 0, j = 0; i < l; i++) { out[j++] = DIGITS[(0xF0 & bytes[i]) >>> 4]; out[j++] = DIGITS[0x0F & bytes[i]]; } return new String(out); } }