/** * Calculates the SHA-512 digest and returns the value as a <code>byte[]</code>. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data * Data to digest * @return SHA-512 digest * @since 1.4 */ public static byte[] sha512(final byte[] data) { return getSha512Digest().digest(data); }
/** * Calculates the SHA-512 digest and returns the value as a <code>byte[]</code>. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data * Data to digest * @return SHA-512 digest * @throws IOException * On error reading from the stream * @since 1.4 */ public static byte[] sha512(final InputStream data) throws IOException { return digest(getSha512Digest(), data); }
/** * Calculates the SHA-512 digest and returns the value as a <code>byte[]</code>. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data * Data to digest * @return SHA-512 digest * @since 1.4 */ public static byte[] sha512(final byte[] data) { return getSha512Digest().digest(data); }
/** * Calculates the SHA-512 digest and returns the value as a <code>byte[]</code>. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data * Data to digest * @return SHA-512 digest * @since 1.4 */ public static byte[] sha512(final byte[] data) { return getSha512Digest().digest(data); }
/** * Calculates the SHA-512 digest and returns the value as a <code>byte[]</code>. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data * Data to digest * @return SHA-512 digest * @since 1.4 */ public static byte[] sha512(final byte[] data) { return getSha512Digest().digest(data); }
/** * Calculates the SHA-512 digest and returns the value as a <code>byte[]</code>. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data * Data to digest * @return SHA-512 digest * @since 1.4 */ public static byte[] sha512(final byte[] data) { return getSha512Digest().digest(data); }
/** * Calculates the SHA-512 digest and returns the value as a <code>byte[]</code>. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data * Data to digest * @return SHA-512 digest * @since 1.4 */ public static byte[] sha512(final byte[] data) { return getSha512Digest().digest(data); }
static String createKeyId(String username) { byte[] digest = DigestUtils.getSha512Digest() .digest(username.getBytes(StandardCharsets.UTF_8)); return new String(Hex.encodeHex(digest)); }
/** * Calculates the SHA-512 digest and returns the value as a <code>byte[]</code>. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data * Data to digest * @return SHA-512 digest * @throws IOException * On error reading from the stream * @since 1.4 */ public static byte[] sha512(final InputStream data) throws IOException { return digest(getSha512Digest(), data); }
/** * Calculates the SHA-512 digest and returns the value as a <code>byte[]</code>. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data * Data to digest * @return SHA-512 digest * @throws IOException * On error reading from the stream * @since 1.4 */ public static byte[] sha512(final InputStream data) throws IOException { return digest(getSha512Digest(), data); }
/** * Calculates the SHA-512 digest and returns the value as a <code>byte[]</code>. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data * Data to digest * @return SHA-512 digest * @throws IOException * On error reading from the stream * @since 1.4 */ public static byte[] sha512(final InputStream data) throws IOException { return digest(getSha512Digest(), data); }
/** * Calculates the SHA-512 digest and returns the value as a <code>byte[]</code>. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data * Data to digest * @return SHA-512 digest * @throws IOException * On error reading from the stream * @since 1.4 */ public static byte[] sha512(final InputStream data) throws IOException { return digest(getSha512Digest(), data); }
/** * Calculates the SHA-512 digest and returns the value as a <code>byte[]</code>. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data * Data to digest * @return SHA-512 digest * @throws IOException * On error reading from the stream * @since 1.4 */ public static byte[] sha512(final InputStream data) throws IOException { return digest(getSha512Digest(), data); }
SignatureGenerator(X509Certificate signer, PrivateKey key) throws GeneralSecurityException, IOException { // this is for computing a digest sha1 = DigestUtils.getSha1Digest(); sha512 = DigestUtils.getSha512Digest(); DigestOutputStream dos1 = new DigestOutputStream(new NullOutputStream(), sha1); DigestOutputStream dos512 = new DigestOutputStream(new NullOutputStream(), sha512); // this is for computing a signature sha1sig = Signature.getInstance("SHA1withRSA"); sha1sig.initSign(key); SignatureOutputStream sos1 = new SignatureOutputStream(sha1sig); sha512sig = Signature.getInstance("SHA512withRSA"); sha512sig.initSign(key); SignatureOutputStream sos512 = new SignatureOutputStream(sha512sig); // this is for verifying that signature validates verifier1 = Signature.getInstance("SHA1withRSA"); verifier1.initVerify(signer.getPublicKey()); SignatureOutputStream vos1 = new SignatureOutputStream(verifier1); verifier512 = Signature.getInstance("SHA512withRSA"); verifier512.initVerify(signer.getPublicKey()); SignatureOutputStream vos512 = new SignatureOutputStream(verifier512); out = new TeeOutputStream(new TeeOutputStream(new TeeOutputStream(new TeeOutputStream(new TeeOutputStream(dos1, sos1), vos1), dos512), sos512), vos512); }