GithubHelp home page GithubHelp logo

johnteee / supersha Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chjj/supersha

0.0 2.0 0.0 9 KB

Fast SHA256 for node.js

License: Other

JavaScript 13.51% Python 1.93% C 8.37% C++ 76.19%

supersha's Introduction

supersha

SHA256 exposed to node.js from Pieter Wuille's libsecp256k1. Used in bcoin.

Usage

var supersha = require('supersha');
var data = new Buffer('01020304', 'hex');
var key = new Buffer('05060708', 'hex');

var hash1 = supersha.sha256(data);

var hash2 = supersha.sha256hmac(data, key);

var hash3 = supersha.hash256(data);

console.log('sha256: %s', hash1.toString('hex'));
console.log('sha256 hmac: %s', hash2.toString('hex'));
console.log('double sha256: %s', hash3.toString('hex'));

Outputs:

sha256: 9f64a747e1b97f131fabb6b447296c9b6f0201e79fb3c5356e6c77e89b6a806a
sha256 hmac: 791ff56c5d7624c816777b13d0621b51f144853a371170e13644d63a77b2596f
double sha256: 8de472e2399610baaa7f84840547cd409434e31f5d3bd71e4d947f283874f9c0

Benchmarks

$ node bench.js
crypto.sha256: ops=100000, time=0.555176535, rate=180122.88650
supersha.sha256: ops=100000, time=0.407243698, rate=245553.21664
crypto.hash256: ops=100000, time=0.968488985, rate=103253.62658
supersha.hash256: ops=100000, time=0.482557892, rate=207229.02196
crypto.sha256hmac: ops=100000, time=0.781748435, rate=127918.38848
supersha.sha256hmac: ops=100000, time=0.539863217, rate=185232.10482

License

Copyright (c) 2016, Christopher Jeffrey. (MIT License)

See LICENSE for more info.

supersha's People

Contributors

chjj avatar

Watchers

 avatar  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.