GithubHelp home page GithubHelp logo

andreasbriese / blake2s-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dchest/blake2s-js

0.0 3.0 0.0 346 KB

BLAKE2s cryptographic hash function in JavaScript

Home Page: https://dchest.github.io/blake2s-js/

JavaScript 100.00%

blake2s-js's Introduction

BLAKE2s implementation in JavaScript

BLAKE2 is a fast and secure cryptographic hash function.

This is a pure JavaScript implementation of its BLAKE2s flavor (currently without tree mode support).

Build Status

Installation

Via NPM:

$ npm install blake2s-js

Via Bower:

$ bower install blake2s-js

or just download blake2s.min.js.

Usage

new BLAKE2s(digestLength, key)

Creates a new instance of BLAKE2s hash with the given length of digest (default and maximum 32) and an optional secret key (a Uint8Array or Array of bytes).

.update(data[, offset, length])

Updates the hash with data (a Uint8Array or Array of bytes). starting at the given offset (optional, defaults to 0) and consuming the given length (optional, defaults to the length of data minus offset).

.digest()

Returns a Uint8Array with the digest of consumed data. Further updates will throw error. Repeat calls of digest() will return the same digest.

.hexDigest()

Like digest(), but returns a hex-encoded string.

BLAKE2s.digestLength = 32

Maximum digest length.

BLAKE2s.blockLength = 64

Block size of the hash function.

BLAKE2s.keyLength = 32

Maximum key length.

Example

var h = new BLAKE2s(32);
h.update(new Uint8Array([1,2,3]));
h.hexDigest();  // returns string with hex digest
h.digest();     // returns Uint8Array

// Keyed:
var key = new Uint8Array(32);
window.crypto.getRandomValues(key);
var h = new BLAKE2s(32, key);
...

Public domain dedication

Written in 2012-2014 by Dmitry Chestnykh.

To the extent possible under law, the author have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. http://creativecommons.org/publicdomain/zero/1.0/

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.