Author: nextgens
Date: 2006-02-12 20:13:54 +0000 (Sun, 12 Feb 2006)
New Revision: 8031
Modified:
trunk/apps/installer/src/Sha1Test.java
Log:
Sha1Test; code cleanups
Modified: trunk/apps/installer/src/Sha1Test.java
===================================================================
--- trunk/apps/installer/src/Sha1Test.java 2006-02-12 20:04:42 UTC (rev
8030)
+++ trunk/apps/installer/src/Sha1Test.java 2006-02-12 20:13:54 UTC (rev
8031)
@@ -1,7 +1,6 @@
import freenet.support.HexUtil;
import gnu.crypto.hash.*;
-import java.io.File;
import java.io.FileInputStream;
import java.io.BufferedInputStream;
@@ -22,18 +21,14 @@
try{
FileInputStream fis = null;
- File file = null;
BufferedInputStream bis = null;
- long lengthBackup=0;
String result=new String();
// We compute the hash
// http://java.sun.com/developer/TechTips/1998/tt0915.html#tip2
try {
fis = new FileInputStream(args[0]);
- file = new File(args[0]);
bis = new BufferedInputStream(fis);
- lengthBackup=file.length();
int len = 0;
byte[] buffer = new byte[BUFFERSIZE];
while ((len = bis.read(buffer)) > -1) {
@@ -47,13 +42,12 @@
// We read the hash-file
try {
fis = new FileInputStream(args[0]+".sha1");
- file = new File(args[0]+".sha1");
bis = new BufferedInputStream(fis);
- lengthBackup=file.length();
int len = 0;
byte[] buffer = new byte[BUFFERSIZE];
while ((len = bis.read(buffer)) > -1) {
result+=new String(buffer,0,len);
+ System.out.println(len);
}
} finally {
if (bis != null) bis.close();
@@ -71,7 +65,7 @@
System.out.println(HexUtil.bytesToHex(hash.digest()).length());
// now we compare
- if(result.equalsIgnoreCase(HexUtil.bytesToHex(hash.digest())+"
"+args[0])){
+ if(result.equalsIgnoreCase(HexUtil.bytesToHex(hash.digest()))){
System.exit(0);
}else {
System.exit(1);