diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e802d6a --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +Copyright (c) 2012 Phusion + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +This package contains code written by the Keccak authors, which is licensed http://creativecommons.org/publicdomain/zero/1.0/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..0cc3b3f --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# The SHA-3 (Keccak) extension for Ruby + +This Ruby extension implements the SHA-3 (Keccak) 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. + +## Installation + + gem install digest-sha3 + +## 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/sha3' + + # Generate 512-bit digest. + Digest::SHA3.digest("foo") # => "\025\227\204*..." + Digest::SHA3.hexdigest("foo") # => "1597842a..." + + # Generate 224-bit digest. + Digest::SHA3.digest("foo", 224) # => "\332\251M\247..." + Digest::SHA3.hexdigest("foo", 224) # => "daa94da7..." + + # Use this interface to feed data in chunks. 512-bit by default. + digest = Digest::SHA3.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::SHA3.new(224) diff --git a/digest-sha3.gemspec b/digest-sha3.gemspec index 243b347..eed3734 100644 --- a/digest-sha3.gemspec +++ b/digest-sha3.gemspec @@ -5,12 +5,14 @@ Gem::Specification.new do |s| s.version = Digest::SHA3::Version::STRING s.summary = "The SHA-3 (Keccak) hash" s.email = "hongli@phusion.nl" - s.homepage = "https://github.com/phusion/digest-sha3" + s.homepage = "https://github.com/phusion/digest-sha3-ruby" s.description = "The SHA-3 (Keccak) hash." s.authors = ["Hongli Lai", "Keccak authors"] s.extensions << "ext/digest/extconf.rb" s.files = Dir[ + "README.md", + "LICENSE", "digest-sha3.gemspec", "ext/**/*.{c,h,rb}", "lib/**/*"