java.lang.Object
net.i2p.data.SimpleDataStructure
net.i2p.crypto.Hash512
- All Implemented Interfaces:
DataStructure
SHA-512 secure hash algorithm implementation.
This class provides the SHA-512 hash algorithm as specified in FIPS PUB 180-4, producing a 64-byte (512-bit) message digest. SHA-512 offers the highest security level in the SHA-2 family with excellent performance characteristics.
Common uses in I2P include:
- Maximum security requirements for sensitive operations
- Long-term cryptographic key derivation
- Digital signatures with strongest hash protection
- Integrity verification for critical system components
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
Hash512
public Hash512()Hash512.Hash512
public Hash512(byte[] data) IllegalArgumentException if data is not correct length (null is ok).- Parameters:
data- the raw 64 bytes of hash data to wrap, or null for an empty structure- 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