Java tutorial
//package com.java2s; import java.security.*; import java.util.Arrays; public class Main { public static byte[] getMsgKeyHash(byte[] data) { byte[] msgKey = Arrays.copyOfRange(getSHA1hash(data), 4, 20); return msgKey; } 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; } }