kornrunner/keccak
Pure PHP Keccak (SHA-3) implementation with easy static API. Compute Keccak hashes (224/256/384/512) and SHAKE outputs (XOF) without extensions. Includes test suite and coverage, suitable for Ethereum and other crypto use cases.
kornrunner/keccak package provides a pure PHP implementation of the Keccak algorithm (SHA-3), which is critical for applications requiring cryptographic hashing beyond SHA-2. In Laravel, this is particularly useful for:
hash() function where SHA-3 is explicitly required (e.g., in hybrid cryptographic systems).Hash facade primarily relies on OpenSSL, this package enables:
Hash::driver('keccak')) for environments lacking native Keccak support.Keccak) with no external dependencies, making it trivial to integrate into Laravel via Composer.Keccak::hash() and Keccak::shake() methods align with Laravel’s Hash facade, reducing developer friction. Example:
// Replace:
Hash::make($value); // Uses OpenSSL SHA-256 by default
// With:
Keccak::hash($value, 256); // Uses SHA-3/Keccak-256
Hash::extend('keccak', function() {
return function($value, array $options = []) {
return Keccak::hash($value, $options['rounds'] ?? 256);
};
});
This allows switching between drivers dynamically (e.g., Hash::driver('keccak')->make($value)).memory_limit. Requires streaming or chunked processing.Hash::check()) that need Keccak support?paragonie/sodium_compat with SHA3) with better maintenance?hash() or Hash::make() where SHA-3 is required (e.g., blockchain, compliance).Hash::driver('keccak')) for environments without OpenSSL.kornrunner/keccak vs. OpenSSL’s sha3_* for critical use cases (e.g., hash_hmac() alternatives).// Before:
$hash = hash('sha256', $data);
// After:
$hash = Keccak::hash($data, 256);
Hash facade:
// app/Providers/AppServiceProvider.php
Hash::extend('keccak', function() {
return function($value, array $options = []) {
return Keccak::hash($value, $options['rounds'] ?? 256);
};
});
Usage:
Hash::driver('keccak')->make($value);
$this->app->bind('keccak', function() {
return new \kornrunner\Keccak();
});
json_encode() inputs before hashing).composer.json and verify basic functionality in a staging environment.How can I help you explore Laravel packages today?