Package net.i2p.crypto
Class SHA1Hash
- java.lang.Object
-
- net.i2p.data.SimpleDataStructure
-
- net.i2p.crypto.SHA1Hash
-
- All Implemented Interfaces:
DataStructure
public class SHA1Hash extends SimpleDataStructure
Because DSAEngine was abusing Hash for 20-byte hashes- Since:
- 0.8.1
- Author:
- zzz
-
-
Field Summary
Fields Modifier and Type Field Description static intHASH_LENGTH-
Fields inherited from class net.i2p.data.SimpleDataStructure
_data
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description inthashCode()a Hash is a hash, so just use the first 4 bytes for speedintlength()The legal length of the byte array in this data structurevoidreadBytes(InputStream in)Sets the data.voidsetData(byte[] data)Sets the data.-
Methods inherited from class net.i2p.data.SimpleDataStructure
calculateHash, equals, fromBase64, fromByteArray, getData, read, toBase64, toByteArray, toString, writeBytes
-
-
-
-
Field Detail
-
HASH_LENGTH
public static final int HASH_LENGTH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SHA1Hash
public SHA1Hash()
- Since:
- 0.9.9
-
SHA1Hash
public SHA1Hash(byte[] data)
- Throws:
IllegalArgumentException- if data is not 20 bytes (null is ok)
-
-
Method Detail
-
length
public int length()
Description copied from class:SimpleDataStructureThe legal length of the byte array in this data structure- Specified by:
lengthin classSimpleDataStructure
-
setData
public void setData(byte[] data)
Description copied from class:SimpleDataStructureSets the data.- Overrides:
setDatain classSimpleDataStructure- Parameters:
data- of correct length, or null- Throws:
IllegalArgumentException- if data is not 20 bytes (null is ok)
-
readBytes
public void readBytes(InputStream in) throws DataFormatException, IOException
Description copied from class:SimpleDataStructureSets the data.- Specified by:
readBytesin interfaceDataStructure- Overrides:
readBytesin classSimpleDataStructure- Parameters:
in- the stream to read- Throws:
DataFormatException- if the data is improperly formattedIOException- if there was a problem reading the stream
-
hashCode
public int hashCode()
a Hash is a hash, so just use the first 4 bytes for speed- Overrides:
hashCodein classSimpleDataStructure
-
-