Package com.biglybt.core.util
Class SHA1
- java.lang.Object
-
- com.biglybt.core.util.SHA1
-
public final class SHA1 extends java.lang.Object
SHA-1 message digest class.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
cacheBlock
private static int
cacheSize
private java.nio.ByteBuffer
finalBuffer
private int
h0
private int
h1
private int
h2
private int
h3
private int
h4
private long
length
private int
s0
private int
s1
private int
s2
private int
s3
private int
s4
private java.nio.ByteBuffer
saveBuffer
private long
saveLength
-
Constructor Summary
Constructors Constructor Description SHA1()
Create a new SHA-1 message digest hasher.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
completeFinalBuffer(java.nio.ByteBuffer buffer)
byte[]
digest()
Finishes the SHA-1 message digest calculation.byte[]
digest(java.nio.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 void
main(java.lang.String[] args)
void
reset()
Resets the SHA-1 to initial state for a new message digest calculation.void
restoreState()
Restore the digest to its previously-saved state.void
saveState()
Save the current digest state.private void
transform(byte[] ar, int offset)
void
update(java.nio.ByteBuffer buffer)
Starts or continues a SHA-1 message digest calculation.
-
-
-
Field Detail
-
h0
private int h0
-
h1
private int h1
-
h2
private int h2
-
h3
private int h3
-
h4
private int h4
-
finalBuffer
private final java.nio.ByteBuffer finalBuffer
-
saveBuffer
private final java.nio.ByteBuffer 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:
- Constant Field Values
-
cacheBlock
private byte[] cacheBlock
-
-
Method Detail
-
transform
private void transform(byte[] ar, int offset)
-
completeFinalBuffer
private void completeFinalBuffer(java.nio.ByteBuffer buffer)
-
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
public void update(java.nio.ByteBuffer buffer)
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
public byte[] digest(java.nio.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().- 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
public static void main(java.lang.String[] args)
-
-