Class HashFunctions
java.lang.Object
org.episteme.core.mathematics.cryptography.HashFunctions
Cryptographic hash functions.
One-way functions for data integrity, digital signatures, password hashing.
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanconstantTimeEquals(byte[] a, byte[] b) Constant-time comparison to prevent timing attacks.static byte[]hmacSha256(byte[] key, byte[] data) HMAC-SHA256 (keyed hash for message authentication).static byte[]bcrypt-like password hashing (using PBKDF2).static byte[]sha256(byte[] data) SHA-256 hash function.static StringSHA-256 for strings.static byte[]sha512(byte[] data) SHA-512 hash function.static StringSHA-512 for strings.
-
Constructor Details
-
HashFunctions
public HashFunctions()
-
-
Method Details
-
sha256
public static byte[] sha256(byte[] data) SHA-256 hash function.Produces 256-bit (32-byte) hash. Collision-resistant.
-
sha256
-
sha512
public static byte[] sha512(byte[] data) SHA-512 hash function. -
sha512
-
hmacSha256
public static byte[] hmacSha256(byte[] key, byte[] data) HMAC-SHA256 (keyed hash for message authentication). -
pbkdf2
bcrypt-like password hashing (using PBKDF2).Slow by design to resist brute-force attacks.
-
constantTimeEquals
public static boolean constantTimeEquals(byte[] a, byte[] b) Constant-time comparison to prevent timing attacks.
-