The Keccak (draft version of SHA-3) cryptographic hash function
Go to file
Alex Kotov 6d58831f6b
Revert "Fix error"
This reverts commit 8272f335d8.
2019-06-13 18:49:13 +05:00
ext/digest Revert "Fix error" 2019-06-13 18:49:13 +05:00
lib/digest/keccak Bump version (0.0.2) 2019-06-13 17:50:07 +05:00
test Add test cases 2019-06-11 20:42:45 +05:00
.gitignore .gitignore 2019-06-11 19:55:14 +05:00
Gemfile Add Gemfile 2019-06-11 19:57:07 +05:00
LICENSE Add copyright 2019-06-08 16:28:44 +05:00
Makefile Use [ instead of [[ for portability. 2013-05-21 23:26:43 +09:00
README.md Remove invalid image 2019-06-08 17:05:36 +05:00
Rakefile Add Rakefile 2019-06-11 20:22:38 +05:00
digest-keccak.gemspec Add Rakefile 2019-06-11 20:22:38 +05:00

README.md

Digest::Keccak

This Ruby extension implements the Keccak (draft version of SHA-3) cryptographic hash function. It is based on the reference C implementation, version 3.2. The exposed interface is almost identical to that of the digest standard library.

Usage

Keccak supports 5 hash lengths: 224-bit, 256-bit, 384-bit, 512-bit and variable length. Variable length is not supported by this Ruby extension. Unless the user specifies otherwise, this Ruby extension assumes 512-bit.

    require 'digest/keccak'

    # Generate 512-bit digest.
    Digest::Keccak.digest("foo")       # => "\025\227\204*..."
    Digest::Keccak.hexdigest("foo")    # => "1597842a..."

    # Generate 224-bit digest.
    Digest::Keccak.digest("foo", 224)       # => "\332\251M\247..."
    Digest::Keccak.hexdigest("foo", 224)    # => "daa94da7..."

    # Use this interface to feed data in chunks. 512-bit by default.
    digest = Digest::Keccak.new
    digest.update("f")
    digest.update("o")
    digest.update("o")
    digest.digest       # => "\025\227\204*..."
    digest.hexdigest    # => "1597842a..."

    # You can pass a hash length to the constructor.
    digest = Digest::Keccak.new(224)

Running the test suite

Run the test suite as follows:

    make test

A part of the test suite is automatically generated from Keccak's reference test suite.