|
From: <pe...@us...> - 2004-03-05 23:57:35
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29887/src/java/org/neuclear/commons/crypto Modified Files: CryptoTools.java Log Message: New Channels package with nio based channels for various crypto related tasks such as digests, signing, verifying and encoding. DigestsChannel, SigningChannel and VerifyingChannel are complete, but not tested. AbstractEncodingChannel will be used for a Base64/Base32 Channel as well as possibly an xml canonicalization channel in the xmlsig library. Index: CryptoTools.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/CryptoTools.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** CryptoTools.java 19 Feb 2004 15:29:10 -0000 1.14 --- CryptoTools.java 5 Mar 2004 23:43:06 -0000 1.15 *************** *** 2,5 **** --- 2,10 ---- * $Id$ * $Log$ + * Revision 1.15 2004/03/05 23:43:06 pelle + * New Channels package with nio based channels for various crypto related tasks such as digests, signing, verifying and encoding. + * DigestsChannel, SigningChannel and VerifyingChannel are complete, but not tested. + * AbstractEncodingChannel will be used for a Base64/Base32 Channel as well as possibly an xml canonicalization channel in the xmlsig library. + * * Revision 1.14 2004/02/19 15:29:10 pelle * Various cleanups and corrections *************** *** 252,255 **** --- 257,261 ---- import javax.crypto.spec.SecretKeySpec; import java.io.IOException; + import java.io.InputStream; import java.math.BigInteger; import java.security.*; *************** *** 500,503 **** --- 506,520 ---- } + public static byte[] digest(final InputStream is) throws IOException { + Digest digest = new org.bouncycastle.crypto.digests.SHA1Digest(); + byte buf[] = new byte[digest.getDigestSize()]; + int length = 0; + while ((length = is.read(buf)) >= 0) + digest.update(buf, 0, length); + digest.doFinal(buf, 0); + is.close(); + return buf; + } + public static byte[] digest(final byte[] value) { final Digest dig = new org.bouncycastle.crypto.digests.SHA1Digest(); |