List of usage examples for org.bouncycastle.crypto.io DigestInputStream getDigest
public Digest getDigest()
From source file:com.github.horrorho.inflatabledonkey.file.FileStreamWriter.java
License:Open Source License
public static boolean copy(InputStream in, OutputStream out, Optional<XFileKey> keyCipher, Optional<byte[]> signature) throws IOException { Digest digest = signature.flatMap(FileSignature::type).orElse(FileSignature.ONE).newDigest(); DigestInputStream digestInputStream = new DigestInputStream(in, digest); IOUtils.copyLarge(decryptStream(digestInputStream, keyCipher), out, new byte[BUFFER_SIZE]); out.flush();//from w w w.j a v a 2 s . com return testSignature(digestInputStream.getDigest(), signature); }
From source file:com.stg.crypto.IODigestUtility.java
License:Open Source License
public static String getDigestChecksum(DigestInputStream dis) { byte[] bytes = new byte[dis.getDigest().getDigestSize()]; dis.getDigest().doFinal(bytes, 0);/*from w w w . ja va2 s. com*/ return CryptoHelper.toString(Hex.encode(bytes)); }