Author: jflesch
Date: 2007-04-14 22:43:08 +0000 (Sat, 14 Apr 2007)
New Revision: 12734

Modified:
   trunk/apps/Thaw/src/thaw/fcp/SHA256Computer.java
Log:
Try to fix the way SHA256 is computed in Thaw

Modified: trunk/apps/Thaw/src/thaw/fcp/SHA256Computer.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/SHA256Computer.java    2007-04-14 22:42:33 UTC 
(rev 12733)
+++ trunk/apps/Thaw/src/thaw/fcp/SHA256Computer.java    2007-04-14 22:43:08 UTC 
(rev 12734)
@@ -20,6 +20,8 @@

        private String file;

+       public final static int BLOCK_SIZE = 32768; /* 32 Ko */
+
        public SHA256Computer(String header, String fileToHash) {
                file = fileToHash;

@@ -33,9 +35,12 @@
                try {
                        FileInputStream in = new FileInputStream(file);

-                       byte[] raw = new byte[32768]; /* 32 Ko */
+                       byte[] raw = new byte[BLOCK_SIZE];

                        while(in.available() > 0) {
+                               if (in.available() < BLOCK_SIZE)
+                                       raw = new byte[in.available()];
+
                                in.read(raw);
                                sha.update(raw);
                        }


Reply via email to