GithubHelp home page GithubHelp logo

isabella232 / digest-sha3-ruby Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phusion/digest-sha3-ruby

0.0 0.0 0.0 2.17 MB

SHA-3 (Keccak) extension for Ruby

License: Other

Ruby 8.05% C 91.00% Makefile 0.95%

digest-sha3-ruby's Introduction

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

Note: as of version 1.1.0, digest-sha3 requires Ruby 2.2. The last version that worked on older versions was 1.0.2.

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)

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.

Warning

Do not use SHA-3 for hashing passwords. Do not even use SHA-3 + salt for hashing passowords. Use a slow hash instead.

See also

node-sha3

digest-sha3-ruby's People

Contributors

bramski avatar foobarwidget avatar knu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.