|
|||||||||||
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 SHA1Hash s 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
SHA1Hash
s 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 hashpublic 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 SecureHash
clone
in class Object
CloneNotSupportedException
- if clone() is not supportedpublic int compareTo(Object o) throws ClassCastException
SHA1Hash
to another
Object
compareTo
in interface Comparable
o
- SHA1Hash
this < o
, 0 if this == o
,
or 1 if this > o
.
ClassCastException
- if o
is not a SHA1Hashpublic int size()
size
in interface SecureHash
public boolean isNull()
isNull
in interface SecureHash
public SecureHash nullHash()
nullHash
in interface SecureHash
public byte[] bytes()
bytes
in interface SecureHash
public boolean equals(Object other)
equals
in interface SecureHash
equals
in class Object
other
- the object with which to compare this SecureHash
public int hashCode()
hashCode
in interface SecureHash
hashCode
in class Object
public long lower64bits()
public void hash(byte[] bytes, int offset, int len)
hash
in interface SecureHash
bytes
- 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 SecureHash
bytes
- the byte array over which to hashpublic void hash(QuickSerializable o)
hash
in interface SecureHash
o
- the object over which to hashpublic void hash(String str)
hash
in interface SecureHash
str
- the String over which to hashpublic 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 SecureHash
o
- the object over which to hash
public String toString()
toString
in interface SecureHash
toString
in class Object
public String fullString()
fullString
in interface SecureHash
public void serialize(OutputBuffer buffer)
QuickSerializable
buffer
.
serialize
in interface QuickSerializable
buffer
- 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 |