Here you can find the source of sha1hash(Collection
Parameter | Description |
---|---|
nquads | a parameter |
private static String sha1hash(Collection<String> nquads)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Collection; public class Main { /**//from w w w . ja v a2s .c o m * A helper class to sha1 hash all the strings in a collection * * @param nquads * @return */ private static String sha1hash(Collection<String> nquads) { try { // create SHA-1 digest final MessageDigest md = MessageDigest.getInstance("SHA-1"); for (final String nquad : nquads) { md.update(nquad.getBytes("UTF-8")); } return encodeHex(md.digest()); } catch (final NoSuchAlgorithmException e) { throw new RuntimeException(e); } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); } } private static String encodeHex(final byte[] data) { String rval = ""; for (final byte b : data) { rval += String.format("%02x", b); } return rval; } }