Java SHA1 sha1sum(byte[] data, Integer startIdxInc, Integer stopIdxExc)

Here you can find the source of sha1sum(byte[] data, Integer startIdxInc, Integer stopIdxExc)

Description

shasum

License

Apache License

Declaration

public static byte[] sha1sum(byte[] data, Integer startIdxInc, Integer stopIdxExc)
            throws NoSuchAlgorithmException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;

public class Main {
    public static byte[] sha1sum(byte[] data, Integer startIdxInc, Integer stopIdxExc)
            throws NoSuchAlgorithmException {
        byte[] out;
        MessageDigest md;/*  w ww  .j  av  a2  s. co  m*/
        md = MessageDigest.getInstance("SHA-1");
        out = md.digest(data);
        if (startIdxInc != null && stopIdxExc != null) {
            out = Arrays.copyOfRange(out, startIdxInc, stopIdxExc);
        }
        return out;
    }

    public static byte[] sha1sum(byte[] data) throws NoSuchAlgorithmException {
        return sha1sum(data, null, null);
    }
}

Related

  1. sha1Hex(byte[] bytes)
  2. sha1Hex(String data)
  3. sha1hex(String source)
  4. sha1Java(String password)
  5. sha1Sum(byte[] ba)
  6. sha1sum(byte[] input, int length)
  7. sha1sum(File file)
  8. sha1sum(File file)
  9. SHA1Sum(final @Nonnull byte[] bytes)