Replaces instances of getBytes() in core classes

This commit is contained in:
z3r0fox
2015-12-20 01:18:38 +00:00
parent 0b94d866f0
commit c60f3970d1
26 changed files with 57 additions and 49 deletions

View File

@@ -9,6 +9,8 @@ import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.security.NoSuchAlgorithmException;
import net.i2p.data.DataHelper;
/**
* Class for generation and parsing of <a href="http://www.hashcash.org/">HashCash</a><br>
* Copyright 2006 Gregory Rubin <a href="mailto:grrubin@gmail.com">grrubin@gmail.com</a><br>
@@ -61,7 +63,7 @@ public class HashCash implements Comparable<HashCash> {
myExtensions = deserializeExtensions(parts[index++]);
MessageDigest md = MessageDigest.getInstance("SHA1");
md.update(cash.getBytes());
md.update(DataHelper.getUTF8(cash));
byte[] tempBytes = md.digest();
int tempValue = numberOfLeadingZeros(tempBytes);
@@ -190,7 +192,7 @@ public class HashCash implements Comparable<HashCash> {
serializeExtensions(extensions) + ":";
result.myToken = generateCash(prefix, value, md);
md.reset();
md.update(result.myToken.getBytes());
md.update(DataHelper.getUTF8(result.myToken));
result.myValue = numberOfLeadingZeros(md.digest());
break;
@@ -294,7 +296,7 @@ public class HashCash implements Comparable<HashCash> {
counter++;
temp = prefix + Long.toHexString(counter);
md.reset();
md.update(temp.getBytes());
md.update(DataHelper.getUTF8(temp));
bArray = md.digest();
tempValue = numberOfLeadingZeros(bArray);
} while ( tempValue < value);