Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 50 lines (31 sloc) 1.748 kb
255d6ad9 » FooBarWidget
2012-10-05 Add documentation and license
1 # The SHA-3 (Keccak) extension for Ruby
2
e19966f3 » FooBarWidget
2012-10-05 Add tests
3 This Ruby extension implements the SHA-3 ([Keccak](http://keccak.noekeon.org/)) cryptographic hashing algorithm. It is based on the reference C implementation, version 3.2. The exposed interface is almost identical to that of the `digest` standard library.
255d6ad9 » FooBarWidget
2012-10-05 Add documentation and license
4
6904cbb8 » FooBarWidget
2012-10-06 Add logo
5 [<img src="http://www.phusion.nl/assets/logo.png">](http://www.phusion.nl/)
6
255d6ad9 » FooBarWidget
2012-10-05 Add documentation and license
7 ## Installation
8
9 gem install digest-sha3
10
11 ## Usage
12
13 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.
14
15 require 'digest/sha3'
16
17 # Generate 512-bit digest.
18 Digest::SHA3.digest("foo") # => "\025\227\204*..."
19 Digest::SHA3.hexdigest("foo") # => "1597842a..."
20
21 # Generate 224-bit digest.
22 Digest::SHA3.digest("foo", 224) # => "\332\251M\247..."
23 Digest::SHA3.hexdigest("foo", 224) # => "daa94da7..."
24
25 # Use this interface to feed data in chunks. 512-bit by default.
26 digest = Digest::SHA3.new
27 digest.update("f")
28 digest.update("o")
29 digest.update("o")
30 digest.digest # => "\025\227\204*..."
31 digest.hexdigest # => "1597842a..."
32
33 # You can pass a hash length to the constructor.
34 digest = Digest::SHA3.new(224)
e19966f3 » FooBarWidget
2012-10-05 Add tests
35
36 ## Running the test suite
37
38 Run the test suite as follows:
39
40 make test
41
42 A part of the test suite is automatically generated from Keccak's reference test suite.
4774379e » FooBarWidget
2012-10-06 Add warning
43
44 ## Warning
45
46 Do not use SHA-3 for hashing passwords. Do not even use SHA-3 + salt for hashing passowords. Use a [slow hash](http://codahale.com/how-to-safely-store-a-password/) instead.
01194db4 » FooBarWidget
2012-10-06 Add 'see also' section
47
48 ## See also
49
50 [node-sha3](https://github.com/phusion/node-sha3)
Something went wrong with that request. Please try again.