java.lang.Object
net.i2p.data.SimpleDataStructure
net.i2p.crypto.Hash384
- All Implemented Interfaces:
DataStructure
SHA-384 secure hash algorithm implementation.
This class provides the SHA-384 hash algorithm as specified in FIPS PUB 180-4, producing a 48-byte (384-bit) message digest. SHA-384 is part of the SHA-2 family and offers higher security than SHA-256 with similar performance.
Common uses in I2P include:
- Enhanced security requirements for sensitive data
- Digital signature generation with longer hash outputs
- Cryptographic key derivation and verification
Field Summary
FieldsFields inherited from class SimpleDataStructure
_dataConstructor Summary
Method Summary
All MethodsMethods inherited from class SimpleDataStructure
calculateHash, equals, fromBase64, fromByteArray, getData, hashCode, read, readBytes, setData, toBase64, toByteArray, toString, writeBytesModifier and TypeMethodDescriptionSHA256 hash of the byte array, or null if data is null.booleanCompares the raw data only: two different SimpleDataStructure subclasses of the same length holding the same bytes are equal, e.g.voidfromBase64(String data) Data from the base64 string.voidfromByteArray(byte[] data) Does the same thing asSimpleDataStructure.setData(byte[])but null not allowed.byte[]getData()Data reference (not a copy).inthashCode()We assume the data has enough randomness in it, so use the first 4 bytes for speed.protected intread(InputStream in, byte[] target) Repeated reads until the buffer is full or IOException is thrown.voidreadBytes(InputStream in) Data read from the stream.voidsetData(byte[] data) The byte array data, or null.toBase64()Renders the structure into modified base 64 notation.byte[]Same thing as getData().toString()Returns a string representation of this data structure.voidwriteBytes(OutputStream out) Writes the data to the output stream.
Field Details
HASH_LENGTH
Constructor Details
Hash384
public Hash384()Hash384.Hash384
public Hash384(byte[] data) IllegalArgumentException if data is not correct length (null is ok).- Parameters:
data- the 48-byte digest to store, or null for an uninitialized hash- Throws:
IllegalArgumentException- if data is not correct length (null is ok)
Method Details
length
public int length()Hash length in bytes.- Specified by:
lengthin classSimpleDataStructure- Returns:
- the hash length in bytes