You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This Ruby extension exposes the [Keccak](http://keccak.noekeon.org/) (SHA-3) digest `C` bindings in the non-final version used by [Ethereum](https://ethereum.org). It is based on the reference `C` implementation, version 3.2. The exposed interface is almost identical to that of the `digest` standard library.
9
+
This Ruby extension exposes the [Keccak](http://keccak.noekeon.org/) (SHA3) digest `C` bindings in the non-final version used by [Ethereum](https://ethereum.org). It is based on the reference `C` implementation, version 3.2. The exposed interface is almost identical to that of the `digest` standard library. See [#16](https://github.com/q9f/keccak.rb/pull/16).
10
+
11
+
:warning:**Note: version `~> 1.3` exposes `digest/keccak` (`Digest::Keccak`) whereas version `~> 1.2` maintains the old `digest/sha3` (`Digest::SHA3`) for backward compatibility.** Only use `~> 1.2` if you want to lazy-patch your library. It works, but it's _not recommended._ Use `~> 1.3` and simply rename SHA3 to Keccak.
10
12
11
13
## Installation
12
14
@@ -18,36 +20,36 @@ gem install keccak
18
20
```
19
21
20
22
```ruby
21
-
gem 'keccak', '~> 1.2'
23
+
gem 'keccak', '~> 1.3'
22
24
```
23
25
24
-
**Note**: as of version `v1.1.0`, `digest-sha3` (historic name, see below) requires Ruby 2.2. The new `keccak` version `v1.2.0` now also supports Ruby 3.0. The last version that worked on older Ruby (1.x) versions was `v1.0.2`. It can be found at the no longer maintained `digest-sha3`[repository from 2015](https://github.com/phusion/digest-sha3-ruby/releases/tag/release-1.0.2).
26
+
**Note**: as of version `~> v1.1`, `digest-sha3` (historic name, see below) requires Ruby 2.2. The new `keccak` version `~> v1.2` now also supports Ruby 3.0. The last version that worked on older Ruby (1.x) versions was `~> v1.0`. It can be found at the no longer maintained `digest-sha3`[repository from 2015](https://github.com/phusion/digest-sha3-ruby/releases/tag/release-1.0.2).
25
27
26
28
## Usage
27
29
28
-
This gem extends the `digest/*` module by a `digest/sha3` class (historic reference, see history section below).
30
+
This gem extends the `digest/*` module by a `digest/keccak` class.
# Use this interface to feed data in chunks. 512-bit by default.
42
-
digest =Digest::SHA3.new
44
+
digest =Digest::Keccak.new
43
45
digest.update("f")
44
46
digest.update("o")
45
47
digest.update("o")
46
48
digest.digest # => "\025\227\204*..."
47
49
digest.hexdigest # => "1597842a..."
48
50
49
51
# You can pass a hash length to the constructor.
50
-
digest =Digest::SHA3.new(224)
52
+
digest =Digest::Keccak.new(224)
51
53
```
52
54
53
55
Keccak supports five 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.
@@ -63,13 +65,13 @@ make test
63
65
64
66
A part of the test suite is automatically generated from Keccak's reference test suite.
65
67
66
-
## Warning: Keccak vs. SHA-3
68
+
## Warning: Keccak vs. SHA3
67
69
68
-
**Note:** This gem still uses the `Digest::SHA3` namespace for reasons of backwards compatibility and long-term maintainability. See history section below.
70
+
**Note:** This gem still uses the `Digest::SHA3` namespace in version `~> 1.2`for reasons of backward compatibility and long-term maintainability. See history section below.
69
71
70
-
:warning: This gem does **not** implement the final FIPS202 standard, today known as SHA-3 but rather an early version, commonly referred to as Keccak. The reason why this is kept around, is that Ethereum uses this earler version of Keccak. See also: [Ethereum: Difference between keccak256 and sha3](https://ethereum.stackexchange.com/questions/30369/difference-between-keccak256-and-sha3)
72
+
:warning: This gem does **not** implement the final FIPS202 standard, today known as SHA3 but rather an early version, commonly referred to as Keccak. The reason why this is kept around, is that Ethereum uses this earler version of Keccak. See also: [Ethereum: Difference between keccak256 and sha3](https://ethereum.stackexchange.com/questions/30369/difference-between-keccak256-and-sha3).
71
73
72
-
If you are looking for the final SHA-3 gem, please use the following: https://rubygems.org/gems/sha3
74
+
If you are looking for the final SHA3 gem, please use the following: https://rubygems.org/gems/sha3
73
75
74
76
## History
75
77
@@ -79,5 +81,5 @@ This gem was later patched multiple times:
79
81
80
82
*https://github.com/teamhedge/digest-sha3-ruby (KECCAK, as `digest-sha3-patched`)
81
83
*https://github.com/sydneyitguy/digest-sha3-ruby (KECCAK, as `digest-sha3-patched-ruby-3`)
82
-
*https://github.com/steakknife/digest-sha3-ruby (actual SHA-3, do not use for Ethereum)
84
+
*https://github.com/steakknife/digest-sha3-ruby (actual SHA3, do not use for Ethereum)
83
85
*https://github.com/kotovalexarian/digest-keccak/ (KECCAK, as `digest-keccak`)
0 commit comments