Here you can find the source of sha1(String value)
public static String sha1(String value)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static final char[] LETTERS = "0123456789ABCDEF".toCharArray(); public static String sha1(String value) { try {// w w w . ja v a2 s . c o m return hash(MessageDigest.getInstance("SHA1"), value); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return null; } private static String hash(MessageDigest digest, String src) { return toHexString(digest.digest(src.getBytes())); } private static String toHexString(byte[] bytes) { char[] values = new char[bytes.length * 2]; int i = 0; for (byte b : bytes) { values[i++] = LETTERS[((b & 0xF0) >>> 4)]; values[i++] = LETTERS[b & 0xF]; } return String.valueOf(values); } }