Java tutorial
//package com.java2s; import java.security.*; import java.util.Arrays; public class Main { public static byte[] getAuthKeyHash(byte[] key) { byte[] authKey = Arrays.copyOfRange(getSHA1hash(key), 12, 20); return authKey; } public static byte[] getSHA1hash(byte[] dataByte) { MessageDigest md = null; byte[] sha1hash = new byte[20]; try { md = MessageDigest.getInstance("SHA-1"); md.update(dataByte, 0, dataByte.length); sha1hash = md.digest(); return sha1hash; } catch (NoSuchAlgorithmException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } return null; } }