This commit is contained in:
zzz
2014-05-20 13:22:07 +00:00
parent a766eca283
commit b573dab05f
2 changed files with 17 additions and 4 deletions

View File

@ -31,7 +31,7 @@ abstract class ExtensionHandler {
public static final int ID_DHT = 3;
/** not using the option bit since the compact format is different */
public static final String TYPE_DHT = "i2p_dht";
/** Pieces * SHA1 Hash length, + 25% extra for file names, benconding overhead, etc */
/** Pieces * SHA1 Hash length, + 25% extra for file names, bencoding overhead, etc */
private static final int MAX_METADATA_SIZE = Storage.MAX_PIECES * 20 * 5 / 4;
private static final int PARALLEL_REQUESTS = 3;

View File

@ -525,7 +525,7 @@ public class DataHelper {
return toString(buf, buf.length);
}
private static final byte[] EMPTY_BUFFER = "".getBytes();
private static final byte[] EMPTY_BUFFER = new byte[0];
/**
* Lower-case hex with leading zeros.
@ -551,10 +551,18 @@ public class DataHelper {
return out.toString();
}
/**
* Positive decimal without leading zeros.
* @param data may be null (returns "0")
* @param len unused
* @return (new BigInteger(1, buf)).toString()
* @deprecated unused
*/
public static String toDecimalString(byte buf[], int len) {
if (buf == null) buf = EMPTY_BUFFER;
if (buf == null)
return "0";
BigInteger val = new BigInteger(1, buf);
return val.toString(10);
return val.toString();
}
/**
@ -568,6 +576,11 @@ public class DataHelper {
return bi.toString(16);
}
/**
* @param val non-null, may have leading minus sign
* @return minimum-length representation (with possible leading 0 byte)
* @deprecated unused
*/
public final static byte[] fromHexString(String val) {
BigInteger bv = new BigInteger(val, 16);
return bv.toByteArray();