|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--ostore.util.SHA1Hash
SHA1Hash is the hash class used by all entities which are SHA1 hashes. (In the prototype, this means Guids and VHashes).
| Field Summary | |
|---|---|
protected byte[] |
_bytes
These are the bytes in this Hash. |
static SecureHash |
FIRST_HASH
This is first hash SHA1 |
static SecureHash |
LAST_HASH
This is last hash SHA1 |
static SHA1Hash |
NULL_HASH
This is the null hash for SHA1 |
static byte[] |
NULL_HASH_VALUE
This is the value of the null hash for SHA1 |
static int |
NUM_BYTES
The number of bytes all SHA1Hashs are composed of |
| Constructor Summary | |
|---|---|
SHA1Hash()
default constructor (creates null hash) |
|
SHA1Hash(byte[] bytes)
hashes the given buffer to create a new SHA1Hash |
|
SHA1Hash(byte[] bytes,
boolean fake)
takes the byte array and just uses it. way to control what your guids look like |
|
SHA1Hash(byte[] bytes,
int offset,
int len)
hashes the given buffer to create a new SHA1Hash |
|
SHA1Hash(InputBuffer buffer)
Construct out of an input buffer. |
|
SHA1Hash(QuickSerializable d)
hashes over the input object |
|
SHA1Hash(SHA1Hash shash)
copy constructor (creates new hash with value of old hash) |
|
SHA1Hash(SHA1HashBuffer buffer)
Computes and returns the digest of the specified buffer. |
|
SHA1Hash(String s)
hashes over the bytes of the input String |
|
| Method Summary | |
|---|---|
byte[] |
bytes()
Returns the bytes contained in this hash |
Object |
clone()
Create an exact copy of this hash |
int |
compareTo(Object o)
This routine compares this SHA1Hash to another
Object |
static void |
concatenateHashes(SHA1Hash hash1,
SHA1Hash hash2,
byte[] buf)
This routine concatenates two hashes and stores the result in the input byte array. |
boolean |
equals(Object other)
Compares this SecureHash with another hash, and returns true iff they are the same type of hash and have the same byte representation |
String |
fullString()
Converts all bytes of this SecureHash to a human-readable String |
void |
hash(byte[] bytes)
Hashes over the input bytes |
void |
hash(byte[] bytes,
int offset,
int len)
Hashes over the input bytes, starting at offset, going for len |
void |
hash(QuickSerializable o)
Hashes over a QuickSerializable object |
void |
hash(String str)
Hashes over the bytes of the input String |
int |
hashCode()
Calculates a Java hash code for this SecureHash object (by taking its lower order bytes) |
boolean |
isNull()
Determines if this SecureHash is a NULL hash or not. |
long |
lower64bits()
Calculates a Java hash code for this SecureHash object (by taking its lower order bytes) |
static void |
main(String[] args)
Measures the speed of various hash implementations. |
SecureHash |
nullHash()
Returns the implementation's NULL hash (typically all zeroes). |
void |
serialize(OutputBuffer buffer)
Add the object to the buffer. |
int |
size()
Return the number of bytes used in the representation of this hash (for example, SHA1 uses 20 bytes) |
String |
toString()
Converts a few bytes of this SecureHash to a human-readable String |
boolean |
verify(QuickSerializable o)
Verifies a QuickSerializable object |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int NUM_BYTES
SHA1Hashs are composed of
public static final byte[] NULL_HASH_VALUE
public static final SecureHash FIRST_HASH
public static final SecureHash LAST_HASH
public static final SHA1Hash NULL_HASH
protected byte[] _bytes
| Constructor Detail |
public SHA1Hash()
public SHA1Hash(SHA1Hash shash)
shash - == old hash whose value we are to copypublic SHA1Hash(byte[] bytes)
SHA1Hash
bytes - the array of bytes over which to hash
public SHA1Hash(byte[] bytes,
boolean fake)
public SHA1Hash(byte[] bytes,
int offset,
int len)
SHA1Hash
bytes - the array of bytes over which to hashoffset - in bytes at which to start hashinglen - of bytes over which to hashpublic SHA1Hash(InputBuffer buffer)
public SHA1Hash(String s)
s - string over which to hashpublic SHA1Hash(QuickSerializable d)
d - object over which to hashpublic SHA1Hash(SHA1HashBuffer buffer)
buffer - A SecureHashBuffer.| Method Detail |
public Object clone()
throws CloneNotSupportedException
clone in interface SecureHashclone in class ObjectCloneNotSupportedException - if clone() is not supported
public int compareTo(Object o)
throws ClassCastException
SHA1Hash to another
Object
compareTo in interface Comparableo - SHA1Hash
this < o, 0 if this == o,
or 1 if this > o.
ClassCastException - if o is not a SHA1Hashpublic int size()
size in interface SecureHashpublic boolean isNull()
isNull in interface SecureHashpublic SecureHash nullHash()
nullHash in interface SecureHashpublic byte[] bytes()
bytes in interface SecureHashpublic boolean equals(Object other)
equals in interface SecureHashequals in class Objectother - the object with which to compare this SecureHash
public int hashCode()
hashCode in interface SecureHashhashCode in class Objectpublic long lower64bits()
public void hash(byte[] bytes,
int offset,
int len)
hash in interface SecureHashbytes - array over which to hashoffset - in bytes[] at which to begin hashinglen - of bytes over which to hashpublic void hash(byte[] bytes)
hash in interface SecureHashbytes - the byte array over which to hashpublic void hash(QuickSerializable o)
hash in interface SecureHasho - the object over which to hashpublic void hash(String str)
hash in interface SecureHashstr - the String over which to hash
public static void concatenateHashes(SHA1Hash hash1,
SHA1Hash hash2,
byte[] buf)
hash1 - the first hash to concatenatehash2 - the second hash to concatenatebuf - the byte array in which to storet the concatenationpublic boolean verify(QuickSerializable o)
verify in interface SecureHasho - the object over which to hash
public String toString()
toString in interface SecureHashtoString in class Objectpublic String fullString()
fullString in interface SecureHashpublic void serialize(OutputBuffer buffer)
QuickSerializablebuffer.
serialize in interface QuickSerializablebuffer - the output buffer to add the object topublic static void main(String[] args)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||