Java tutorial
//package com.java2s; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static byte[] encryptSHA1(byte[] data) { return encryptAlgorithm(data, "SHA-1"); } private static byte[] encryptAlgorithm(byte[] data, String algorithm) { try { MessageDigest md = MessageDigest.getInstance(algorithm); md.update(data); return md.digest(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return new byte[0]; } }