Here you can find the source of sha1Hex(String data)
static String sha1Hex(String data)
//package com.java2s; //License from project: Apache License import javax.xml.bind.DatatypeConverter; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { static String sha1Hex(String data) { MessageDigest digest = null; try {//ww w . ja v a 2 s.c o m digest = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } try { digest.update(data.getBytes("utf8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } byte[] digestBytes = digest.digest(); return DatatypeConverter.printHexBinary(digestBytes); } }