Code Monkey home page Code Monkey logo

blake2.wasm's Introduction

blake2.wasm Travis CI

BLAKE2b and BLAKE2s hash functions compiled to WebAssembly using Emscripten and optimized for small size

For pure JavaScript implementation that is not performance-critical you might want to consider blakejs instead.

How to install

npm install blake2.wasm

How to use

Node.js:

var blake2 = require('blake2.wasm')

blake2.ready(function () {
    // Do stuff
});

Browser:

requirejs(['blake2.wasm'], function (blake2) {
    blake2.ready(function () {
        // Do stuff
    });
})

API

blake2.ready(callback)

  • callback - Callback function that is called when WebAssembly is loaded and library is ready for use

blake2.Blake2b(output_length = 64 : number, key = null : Uint8Array) : Blake2b

Create Blake2b object that can later be updated with data

  • output_length - Length of output hash in bytes, defaults to full 512-bit hash (64 bytes)
  • key - Secret key

blake2.Blake2b.update(input : Uint8Array) : Blake2b

Update instance with data

blake2.Blake2b.final() : Uint8Array

Get hash

blake2.Blake2s(output_length = 32 : number, key = null : Uint8Array) : Blake2s

Create Blake2s object that can later be updated with data

  • output_length - Length of output hash in bytes, defaults to full 256-bit hash (32 bytes)
  • key - Secret key

blake2.Blake2s.update(input : Uint8Array) : Blake2s

Update instance with data

blake2.Blake2s.final() : Uint8Array

Get hash

Take a look at src/index.ls for JsDoc sections with arguments and return types as well as methods description, look at tests/index.ls for usage examples.

Contribution

Feel free to create issues and send pull requests (for big changes create an issue first and link it from the PR), they are highly appreciated!

When reading LiveScript code make sure to configure 1 tab to be 4 spaces (GitHub uses 8 by default), otherwise code might be hard to read.

License

Free Public License 1.0.0 / Zero Clause BSD License

https://opensource.org/licenses/FPL-1.0.0

https://tldrlegal.com/license/bsd-0-clause-license

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.