mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-15 03:35:52 +00:00
Clarify some parameter names in Sha256Hash and add a utility method.
This commit is contained in:
parent
7e8ed913ec
commit
7fc325900c
@ -41,18 +41,18 @@ public class Sha256Hash implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* Creates a Sha256Hash by wrapping the given byte array. It must be 32 bytes long.
|
* Creates a Sha256Hash by wrapping the given byte array. It must be 32 bytes long.
|
||||||
*/
|
*/
|
||||||
public Sha256Hash(byte[] bytes) {
|
public Sha256Hash(byte[] rawHashBytes) {
|
||||||
checkArgument(bytes.length == 32);
|
checkArgument(rawHashBytes.length == 32);
|
||||||
this.bytes = bytes;
|
this.bytes = rawHashBytes;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Sha256Hash by decoding the given hex string. It must be 64 characters long.
|
* Creates a Sha256Hash by decoding the given hex string. It must be 64 characters long.
|
||||||
*/
|
*/
|
||||||
public Sha256Hash(String string) {
|
public Sha256Hash(String hexString) {
|
||||||
checkArgument(string.length() == 64);
|
checkArgument(hexString.length() == 64);
|
||||||
this.bytes = Hex.decode(string);
|
this.bytes = Hex.decode(hexString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,6 +67,13 @@ public class Sha256Hash implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the hash of the hash of the contents. This is a standard operation in Bitcoin.
|
||||||
|
*/
|
||||||
|
public static Sha256Hash createDouble(byte[] contents) {
|
||||||
|
return new Sha256Hash(Utils.doubleDigest(contents));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a hash of the given files contents. Reads the file fully into memory before hashing so only use with
|
* Returns a hash of the given files contents. Reads the file fully into memory before hashing so only use with
|
||||||
* small files.
|
* small files.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user