|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.bitcoin.x6763.crypto.digest.SHA1
public class SHA1
The SHA1 provides methods for hashing data with
the SHA-1 digest.
There are two ways this class can be used.
The first way is to use the static hash method, which
will internally instantiate the SHA1 class on each call:
byte[] data = new String("abc").getBytes();
byte[] hash = SHA1.hash(data);
The second way is to instantiate a SHA1 object and use the hashBytes
instance method. Each call to hashBytes resets the SHA1 digest, so
each hash does not affect the next.
SHA1 sha1 = new SHA1();
byte[] data1 = new String("abc").getBytes();
byte[] hash1 = sha1.hashBytes(data1);
byte[] data2 = new String("def").getBytes();
byte[] hash2 = sha1.hashBytes(data2);
The update and digest instance methods can also be used
directly, as well.
| Constructor Summary | |
|---|---|
SHA1()
Creates a SHA1 digest instance. |
|
| Method Summary | |
|---|---|
byte[] |
digest()
Completes the SHA-1 hash computation by performing the final operations such as padding. |
byte[] |
digest(byte data)
Completes the SHA-1 hash computation by performing the final operations such as padding. |
byte[] |
digest(byte[] data)
Completes the SHA-1 hash computation by performing the final operations such as padding. |
byte[] |
digest(byte[] data,
int offset,
int length)
Completes the SHA-1 hash computation by performing the final operations such as padding. |
static byte[] |
hash(byte[] data)
Hashes an array of bytes with the SHA-1 algorithm. |
byte[] |
hashBytes(byte[] data)
Hashes an array of bytes with the SHA-1 algorithm. |
void |
update(byte data)
Updates the SHA-1 digest using the specified byte. |
void |
update(byte[] data)
Updates the SHA-1 digest using the specified array of bytes |
void |
update(byte[] data,
int offset,
int length)
Updates the SHA-1 digest using the specified array of bytes, starting at the specified offset. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SHA1()
| Method Detail |
|---|
public static byte[] hash(byte[] data)
data - the array of bytes to hash
public byte[] hashBytes(byte[] data)
data - the array of bytes to hash
public void update(byte data)
data - the byte with which to update the digestpublic void update(byte[] data)
data - the array of bytes to hash
public void update(byte[] data,
int offset,
int length)
data - the array of bytes to hashoffset - the offset to start from in the array of byteslength - the number of bytes to use, starting at offsetpublic byte[] digest()
public byte[] digest(byte data)
data - the byte to be updated before the digest is completed
public byte[] digest(byte[] data)
data - the array of bytes to be updated before the digest is completed
public byte[] digest(byte[] data,
int offset,
int length)
data - the array of bytes to be updated before the digest is completedoffset - the offset to start from in the array of byteslength - the number of bytes to use, starting at offset
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||