Class SHA1
java.lang.Object
com.ugos.crypt.hash.SHA1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]private intprivate longprivate int[]private static final intprivate int[]private static final intprivate byte[]private int[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidbyte2int(byte[] src, int srcOffset, int[] dst, int dstOffset, int length) byte[]digest()(package private) byte[]Calculates the final digest.private byte[]engineDigest(byte[] in, int pos) Returns the digest of all data added (previous and buffered) and resets the digest.private voidInitializes (resets) the message digest.private voidengineTransform(byte[] in) Transform (add) a data block to the message digest.(package private) voidengineUpdate(byte b) Updates the message digest with a single byte of new data.(package private) voidengineUpdate(byte[] data, int offset, int length) Updates the message digest with new data.private static intf1(int a, int b, int c) private static intf2(int a, int b, int c) private static intf3(int a, int b, int c) private static intf4(int a, int b, int c) byte[]getSHA1Hash(byte[] input) This method accepts a byte array and returns a SHA-1 secure one-way hash value of it, as a byte array.byte[]getSHA1Hash(String str) This method accepts a string and returns a SHA-1 secure one-way hash value of that string, as a byte array.static byte[]hash(byte[] input) This method accepts a string and returns a SHA-1 secure one-way hash value of that string, as a byte array.static byte[]voidreset()private voidtransform(int[] X) voidupdate(byte[] input)
-
Field Details
-
HASH_LENGTH
private static final int HASH_LENGTH- See Also:
-
DATA_LENGTH
private static final int DATA_LENGTH- See Also:
-
buffer
private byte[] buffer -
buffered
private int buffered -
count
private long count -
digest
private int[] digest -
data
private int[] data -
z
private int[] z -
tmp
private byte[] tmp
-
-
Constructor Details
-
SHA1
public SHA1()Constructs a SHA-1 message digest.
-
-
Method Details
-
hash
public static byte[] hash(byte[] input) This method accepts a string and returns a SHA-1 secure one-way hash value of that string, as a byte array. -
hash
-
getSHA1Hash
This method accepts a string and returns a SHA-1 secure one-way hash value of that string, as a byte array. -
getSHA1Hash
public byte[] getSHA1Hash(byte[] input) This method accepts a byte array and returns a SHA-1 secure one-way hash value of it, as a byte array. -
update
public void update(byte[] input) -
reset
public void reset() -
digest
public byte[] digest() -
engineReset
private void engineReset()Initializes (resets) the message digest. -
engineUpdate
void engineUpdate(byte b) Updates the message digest with a single byte of new data. -
engineUpdate
void engineUpdate(byte[] data, int offset, int length) Updates the message digest with new data.- Parameters:
data- the data to be added.offset- the start of the data in the array.length- the number of bytes of data to add.
-
engineDigest
byte[] engineDigest()Calculates the final digest. -
engineDigest
private byte[] engineDigest(byte[] in, int pos) Returns the digest of all data added (previous and buffered) and resets the digest.- Returns:
- the digest of all the data added to the message digest as a byte array.
-
engineTransform
private void engineTransform(byte[] in) Transform (add) a data block to the message digest. -
byte2int
private static void byte2int(byte[] src, int srcOffset, int[] dst, int dstOffset, int length) -
f1
private static int f1(int a, int b, int c) -
f2
private static int f2(int a, int b, int c) -
f3
private static int f3(int a, int b, int c) -
f4
private static int f4(int a, int b, int c) -
transform
private void transform(int[] X)
-