Java tutorial
//package com.java2s; import java.io.UnsupportedEncodingException; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String getSHA1Digest(final String pInput) { if (pInput != null) { try { final MessageDigest lDigest = MessageDigest.getInstance("SHA1"); lDigest.update(getBytes(pInput)); final BigInteger lHashInt = new BigInteger(1, lDigest.digest()); return String.format("%1$032X", lHashInt); } catch (final NoSuchAlgorithmException lException) { return pInput; } } return null; } public static byte[] getBytes(final String s) { try { return s.getBytes("UTF-8"); } catch (final UnsupportedEncodingException e) { return s.getBytes(); } } }