Digest Lite
digest-lite gem - crypto(graphic) hash functions / classes - Digest::KeccakLite (512bit, 256bit, etc), Digest::SHA3Lite (512bit, 256bit, etc) in "100% pure" ruby "lite" scripts, that is, without any c-extensions and with zero-dependency
Background - Digest - The Standard Built-In Module / Library For Crypto(graphic) Hash Function Algorithms
In Ruby's standard Digest module the following crypto(graphic) hash function algorithms / classes
are available:
- MD5 (128 bits / 16 bytes) -- Message-Digest Algorithm by RSA Data Security, Inc., described in RFC1321.
- RIPEMD-160 / RMD160 (160 bits / 20 bytes) -- RIPEMD-160 cryptographic hash function, designed by Hans Dobbertin, Antoon Bosselaers, and Bart Preneel.
- SHA1 (160 bits / 20 bytes) -- Secure Hash Algorithm by NIST (the US' National Institute of Standards and Technology), described in FIPS PUB 180-1.
- SHA2 Family -- described in FIPS 180-2.
- SHA512 (512 bits / 64 bytes)
- SHA384 (384 bits / 48 bytes)
- SHA256 (256 bits / 32 bytes)
Example:
require 'digest'
Digest::MD5.hexdigest( 'abc' )
Digest::RMD160.hexdigest( 'abc' )
Digest::SHA1.hexdigest( 'abc' )
Digest::SHA2.new(256).hexdigest( 'abc' )
Digest::SHA256.hexdigest( 'abc' )
Digest::SHA2.new(384).hexdigest 'abc'
Digest::SHA384.hexdigest 'abc'
Digest::SHA2.new(512).hexdigest 'abc'
Digest::SHA512.hexdigest 'abc'
What about the Keccak or SHA3 (family of hash function algorithms)? Read on.
Usage
require 'digest-lite'
Digest::KeccakLite.new( 256 ).hexdigest( 'abc' )
Digest::KeccakLite.hexdigest( 'abc', 256 )
Digest::SHA3Lite.new( 224 ).hexdigest( 'abc' )
Digest::SHA3Lite.hexdigest( 'abc', 224 )
Digest::SHA3Lite.new( 256 ).hexdigest( 'abc' )
Digest::SHA3Lite.hexdigest( 'abc', 256 )
Digest::SHA3Lite.new( 384 ).hexdigest( 'abc' )
Digest::SHA3Lite.hexdigest( 'abc', 384 )
Digest::SHA3Lite.new( 512 ).hexdigest( 'abc' )
Digest::SHA3Lite.hexdigest( 'abc', 512 )
Note: To avoid naming conflicts / errors with
Digest::Keccak
or Digest::SHA3
as used in alternate
digest gems (with or without c-extensions) this gem
uses Digest::KeccakLite
or Digest::SHA3Lite
to let you load different (faster) variants
at the same time.
License
The scripts are dedicated to the public domain.
Use it as you please with no restrictions whatsoever.
Post them on the D.I.Y. Punk (Pixel) Art reddit. Thanks.