Class SHA1
java.lang.Object
com.biglybt.core.util.SHA1
SHA-1 message digest class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]private static final intprivate final ByteBufferprivate intprivate intprivate intprivate intprivate intprivate longprivate intprivate intprivate intprivate intprivate intprivate final ByteBufferprivate long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcompleteFinalBuffer(ByteBuffer buffer) byte[]digest()Finishes the SHA-1 message digest calculation.byte[]digest(ByteBuffer buffer) Finishes the SHA-1 message digest calculation, by first performing a final update from the given input buffer, then completing the calculation as with digest().static voidvoidreset()Resets the SHA-1 to initial state for a new message digest calculation.voidRestore the digest to its previously-saved state.voidSave the current digest state.private voidtransform(byte[] ar, int offset) voidupdate(ByteBuffer buffer) Starts or continues a SHA-1 message digest calculation.
-
Field Details
-
h0
private int h0 -
h1
private int h1 -
h2
private int h2 -
h3
private int h3 -
h4
private int h4 -
finalBuffer
-
saveBuffer
-
s0
private int s0 -
s1
private int s1 -
s2
private int s2 -
s3
private int s3 -
s4
private int s4 -
length
private long length -
saveLength
private long saveLength -
cacheSize
private static final int cacheSize- See Also:
-
cacheBlock
private byte[] cacheBlock
-
-
Constructor Details
-
SHA1
public SHA1()Create a new SHA-1 message digest hasher.
-
-
Method Details
-
transform
private void transform(byte[] ar, int offset) -
completeFinalBuffer
-
reset
public void reset()Resets the SHA-1 to initial state for a new message digest calculation. Must be called before starting a new hash calculation. -
update
Starts or continues a SHA-1 message digest calculation. Only the remaining bytes of the given ByteBuffer are used.- Parameters:
buffer- input data
-
digest
public byte[] digest()Finishes the SHA-1 message digest calculation.- Returns:
- 20-byte hash result
-
digest
Finishes the SHA-1 message digest calculation, by first performing a final update from the given input buffer, then completing the calculation as with digest().- Parameters:
buffer- input data- Returns:
- 20-byte hash result
-
saveState
public void saveState()Save the current digest state. This allows the resuming of a SHA-1 calculation, even after a digest calculation is finished with digest(). -
restoreState
public void restoreState()Restore the digest to its previously-saved state. -
main
-