Calculates digest and returns the value as a hex string.

@param input  input bytes
@param digest digest algorithm
@return digest as a hex string
160162
public static String dgstHex(byte[] input, Digest digest) {
        checkNotNull(input);
        byte[] dgstBytes = dgst(input, digest);
        return BaseEncoding.base16().encode(dgstBytes);
    }
458962
def sha1_digest(instr):
    '''
    
    '''
    if six.PY3:
        b = salt.utils.stringutils.to_bytes(instr)
        return hashlib.sha1(b).hexdigest()
    return hashlib.sha1(instr).hexdigest()
1151197
public static String digestToFileName(String digest) {
        if (StringUtils.startsWith(digest, "sha1")) {
            return "manifest.json";
        }
        return getShaVersion(digest) + "__" + getShaValue(digest);
    }
1022164
public static String digestMD5(String message, String charset) {
        try {
            byte[] strTemp = message.getBytes(charset);
            MessageDigest mdTemp = MessageDigest.getInstance("MD5");
            mdTemp.update(strTemp);
            byte[] md = mdTemp.digest();
            int j = md.length;
            char[] chars = new char[j * 2];
            int k = 0;
            for (byte b : md) {
                chars[k++] = HEX_DIGITS[b >>> 4 & 0xf];
                chars[k++] = HEX_DIGITS[b & 0xf];
            }
            return new String(chars);
        } catch (Exception e) {
            throw new IllegalArgumentException(e.getMessage(), e);
        }
    }
940535
public static byte[] hashTwice(byte[] input1, byte[] input2) {
        MessageDigest digest = newDigest();
        digest.update(input1);
        digest.update(input2);
        return digest.digest(digest.digest());
    }
963418
public KeyVerifyParameters withDigest(byte[] digest) {
        if (digest == null) {
            this.digest = null;
        } else {
            this.digest = Base64Url.encode(digest);
        }
        return this;
    }
1062078
private static String digestToString(byte[] b) {
        
        StringBuilder result = new StringBuilder(128);
        for (byte aB : b) {
            result.append(Integer.toString((aB & 0xff) + 0x100, 16).substring(1));
        }
        
        return result.toString();
    }
189392
public static String digest(String string, String digestAlgo, String encoding) {
        try {
            MessageDigest digester = MessageDigest.getInstance(digestAlgo);
            digester.update(string.getBytes(encoding));
            return hex(digester.digest());
        } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
125073
public static byte[] doubleDigest(byte[] input, int offset, int length) {
        synchronized (sha256digest) {
            sha256digest.reset();
            sha256digest.update(input, offset, length);
            byte[] first = sha256digest.digest();
            return sha256digest.digest(first);
        }
    }
788582
public static long hash(byte[] digest, int index) {
        long f = ((long) (digest[3 + index * 4] & 0xFF) << 24)
            | ((long) (digest[2 + index * 4] & 0xFF) << 16)
            | ((long) (digest[1 + index * 4] & 0xFF) << 8)
            | (digest[index * 4] & 0xFF);
        return f & 0xFFFFFFFFL;
    }
251583
public static byte[] hash(byte[] input, int offset, int length) {
        MessageDigest digest = newDigest();
        digest.update(input, offset, length);
        return digest.digest();
    }
476319
public String generateDigest(InputStream stream) {
        MessageDigest digest = null;
        try {
            digest = MessageDigest.getInstance(DIGEST_ALGORITHM_SHA1);
        } catch (NoSuchAlgorithmException ae) {
            throw new BoxAPIException("Digest algorithm not found", ae);
        }

        //Calcuate the digest using the stream.
        DigestInputStream dis = new DigestInputStream(stream, digest);
        try {
            int value = dis.read();
            while (value != -1) {
                value = dis.read();
            }
        } catch (IOException ioe) {
            throw new BoxAPIException("Reading the stream failed.", ioe);
        }

        //Get the calculated digest for the stream
        byte[] digestBytes = digest.digest();
        return Base64.encode(digestBytes);
    }
325340
func Digest(r io.Reader) (string, error) {
	hasher := sha256.New()
	if _, err := io.Copy(hasher, r); err != nil {
		return "", err
	}
	digest := hex.EncodeToString(hasher.Sum(nil))
	return digest, nil
}
1350395
function calculate(digest) {
  var offset = digest[19] & 0xf;
  var code = (digest[offset] & 0x7f) << 24 | (digest[offset + 1] & 0xff) << 16 | (digest[offset + 2] & 0xff) << 8 | (digest[offset + 3] & 0xff);
  return code.toString();
}
941333
public static byte[] sha3(byte[] input, int start, int length) {
        Keccak256 digest =  new Keccak256();
        digest.update(input, start, length);
        return digest.digest();
    }
1353696
public static byte[] sha1(@NotNull byte[] input, @Nullable byte[] salt) {
		return digest(input, get(SHA_1_DIGEST), salt, 1);
	}
1109190
public String sha3(String input) {
        String hash = "";
        try {
            SHA3.DigestSHA3 md = new SHA3.DigestSHA3(256);
            md.update(input.getBytes("UTF-8"));
            hash = Hex.toHexString(md.digest());
        } catch (UnsupportedEncodingException e) {
            logger.error("Error while hashing with SHA-3", e);
        }

        return hash;
    }