Package com.ugos.crypt.hash
Class SHA1
- java.lang.Object
-
- com.ugos.crypt.hash.SHA1
-
public final class SHA1 extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]bufferprivate intbufferedprivate longcountprivate int[]dataprivate static intDATA_LENGTHprivate int[]digestprivate static intHASH_LENGTHprivate byte[]tmpprivate int[]z
-
Constructor Summary
Constructors Constructor Description SHA1()Constructs a SHA-1 message digest.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidbyte2int(byte[] src, int srcOffset, int[] dst, int dstOffset, int length)byte[]digest()(package private) byte[]engineDigest()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 voidengineReset()Initializes (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(java.lang.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[]hash(java.lang.String str)voidreset()private voidtransform(int[] X)voidupdate(byte[] input)
-
-
-
Field Detail
-
HASH_LENGTH
private static final int HASH_LENGTH
- See Also:
- Constant Field Values
-
DATA_LENGTH
private static final int DATA_LENGTH
- See Also:
- Constant Field Values
-
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
-
-
Method Detail
-
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
public static byte[] hash(java.lang.String str)
-
getSHA1Hash
public byte[] getSHA1Hash(java.lang.String str)
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)
-
-