/** * Calculates the SHA-384 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-384 digest as a hex string * @since 1.4 */ public static String sha384Hex(byte[] data) { return Hex.encode(sha384(data)); }
/** * Calculates the SHA-512 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-512 digest as a hex string * @since 1.4 */ public static String sha512Hex(String data) { return Hex.encode(sha512(data)); }
/** * Calculates the SHA-256 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-256 digest as a hex string * @since 1.4 */ public static String sha256Hex(byte[] data) { return Hex.encode(sha256(data)); }
/** * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order. * The returned array will be double the length of the passed array, as it takes two characters to represent any * given byte. * * @param data * a byte[] to convert to Hex characters * @return A char[] containing hexadecimal characters */ public static char[] encodeHex(byte[] data) { return encodeHex(data, true); }
/** * Returns an SHA-1 digest. * * @return An SHA-1 digest instance. * @throws RuntimeException when a {@link java.security.NoSuchAlgorithmException} is caught. */ private static MessageDigest getShaDigest() { return getDigest("SHA"); } }
/** * Calculates the MD5 digest and returns the value as a base64 string. */ public static String digest(byte[] data) { return Digests.md5Base64(data); }
/** * Calculates the MD5 digest and returns the value as a base64 string. * * @param data Data to digest * @return MD5 digest as a base64 string * @throws IOException On error reading from the stream * @since 1.4 */ public static String md5Base64(InputStream data) throws IOException { return Base64.encode(md5(data)); }
/** * Calculates the SHA-384 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-384 digest as a hex string * @since 1.4 */ public static String sha384Hex(String data) { return Hex.encode(sha384(data)); }
/** * Calculates the SHA-512 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-512 digest as a hex string * @since 1.4 */ public static String sha512Hex(byte[] data) { return Hex.encode(sha512(data)); }
/** * Calculates the SHA-256 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-256 digest as a hex string * @since 1.4 */ public static String sha256Hex(String data) { return Hex.encode(sha256(data)); }
/** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data Data to digest * @return SHA-1 digest as a hex string * @throws IOException On error reading from the stream * @since 1.4 */ public static String shaHex(InputStream data) throws IOException { return Hex.encode(sha(data)); }
/** * Calculates the MD5 digest and returns the value as a 32 character hex string. * * @param data Data to digest * @return MD5 digest as a hex string * @throws IOException On error reading from the stream * @since 1.4 */ public static String md5Hex(InputStream data) throws IOException { return Hex.encode(md5(data)); }
/** * Calculates the SHA-384 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-384 digest as a hex string * @throws IOException On error reading from the stream * @since 1.4 */ public static String sha384Hex(InputStream data) throws IOException { return Hex.encode(sha384(data)); }
/** * Calculates the SHA-512 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-512 digest as a hex string * @throws IOException On error reading from the stream * @since 1.4 */ public static String sha512Hex(InputStream data) throws IOException { return Hex.encode(sha512(data)); }