Here you can find the source of sha1(String input)
public static String sha1(String input)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Formatter; public class Main { public static String sha1(String input) { MessageDigest sha1;/*w w w . j av a2 s.c o m*/ try { sha1 = MessageDigest.getInstance("SHA1"); } catch (NoSuchAlgorithmException e) { return null; } //not sure what encoding is used in input.. byte[] ret = sha1.digest(input.getBytes()); return byteArray2Hex(ret); } private static String byteArray2Hex(byte[] hash) { Formatter formatter = new Formatter(); for (byte b : hash) { formatter.format("%02x", b); } return formatter.toString(); } }