Here you can find the source of SHA1(ByteBuffer buf, int offset, int size)
public static byte[] SHA1(ByteBuffer buf, int offset, int size) throws NoSuchAlgorithmException
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; import java.security.*; public class Main { public static byte[] SHA1(byte[] buf) throws NoSuchAlgorithmException { MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); return sha1.digest(buf); }//from ww w . j av a 2 s .co m public static byte[] SHA1(ByteBuffer buf, int offset, int size) throws NoSuchAlgorithmException { MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); for (int i = offset; i < offset + size; i++) { sha1.update(buf.get(i)); } return sha1.digest(); } }