/** * Get the string representation of the binary hash of the content read by this reader. This method will return null if * the reader has not yet been closed. * * @return the hex-encoded representation of the binary hash of the contents, or null if the reader has not yet been * closed */ public String getHashAsHexString() { return SecureHash.asHexString(hash); } }
/** * Get the string representation of the binary hash of the content read by this stream. This method will return null if * the stream has not yet been closed. * * @return the hex-encoded representation of the binary hash of the contents, or null if the stream has not yet been * closed */ public String getHashAsHexString() { return SecureHash.asHexString(hash); } }
/** * Get the string representation of the binary hash of the content read by this reader. This method will return null if * the reader has not yet been closed. * * @return the hex-encoded representation of the binary hash of the contents, or null if the reader has not yet been * closed */ public String getHashAsHexString() { return SecureHash.asHexString(hash); } }
/** * Get the string representation of the binary hash of the content read by this reader. This method will return null if * the reader has not yet been closed. * * @return the hex-encoded representation of the binary hash of the contents, or null if the reader has not yet been * closed */ public String getHashAsHexString() { return SecureHash.asHexString(hash); } }
/** * Get the string representation of the binary hash of the content read by this stream. This method will return null if * the stream has not yet been closed. * * @return the hex-encoded representation of the binary hash of the contents, or null if the stream has not yet been * closed */ public String getHashAsHexString() { return SecureHash.asHexString(hash); } }
/** * Get the string representation of the binary hash of the content read by this stream. This method will return null if * the stream has not yet been closed. * * @return the hex-encoded representation of the binary hash of the contents, or null if the stream has not yet been * closed */ public String getHashAsHexString() { return SecureHash.asHexString(hash); } }
/** * Computes the sha1 value for the given string. * * @param string a non-null string * @return the SHA1 value for the given string. */ public static String sha1( String string ) { try { byte[] sha1 = SecureHash.getHash(SecureHash.Algorithm.SHA_1, string.getBytes()); return SecureHash.asHexString(sha1); } catch (NoSuchAlgorithmException e) { throw new SystemFailureException(e); } }
/** * Computes the sha1 value for the given string. * * @param string a non-null string * @return the SHA1 value for the given string. */ public static String sha1( String string ) { try { byte[] sha1 = SecureHash.getHash(SecureHash.Algorithm.SHA_1, string.getBytes()); return SecureHash.asHexString(sha1); } catch (NoSuchAlgorithmException e) { throw new SystemFailureException(e); } }
/** * Computes the sha1 value for the given string. * * @param string a non-null string * @return the SHA1 value for the given string. */ public static String sha1( String string ) { try { byte[] sha1 = SecureHash.getHash(SecureHash.Algorithm.SHA_1, string.getBytes()); return SecureHash.asHexString(sha1); } catch (NoSuchAlgorithmException e) { throw new SystemFailureException(e); } }
/** * {@inheritDoc} */ @Override public String toString() { try { acquire(); StringBuilder sb = new StringBuilder(); sb.append("binary ("); sb.append(getReadableSize()); sb.append(", SHA1="); sb.append(SecureHash.asHexString(getHash())); sb.append(')'); return sb.toString(); } finally { release(); } }
private static String sha1( String content ) { try { byte[] bytes = SecureHash.getHash(Algorithm.SHA_1, new ByteArrayInputStream(content.getBytes())); return SecureHash.asHexString(bytes); } catch (IOException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return null; }