Git Product home page Git Product logo

bcrypt.wasm's Introduction

bcrypt.wasm

Current Version Build Status via Travis CI Dependencies belly-button-style

WebAssembly implementation of bcrypt. This module began life as a quasi-fork of the bcrypt module. Currently, only the synchronous APIs are available.

Basic Usage

'use strict';
const Bcrypt = require('bcrypt.wasm');
const data = 'password';
const salt = Bcrypt.genSaltSync();
const hash = Bcrypt.hashSync(data, salt);

Bcrypt.compareSync(data, hash); // equals true
Bcrypt.compareSync(data + 'x', hash); // equals false

API

bcrypt.wasm exports the following methods.

compareSync(data, hash)

  • Arguments
    • data (string) - Cleartext data to compare against an encrypted hash.
    • hash (string) - An encrypted hash to compare against cleartext input.
  • Returns
    • match (boolean) - true if the comparison succeeds, and false otherwise.

genSaltSync(rounds)

  • Arguments
    • rounds (number) - The cost of generating a salt. Optional. Defaults to 10.
  • Returns
    • salt (string) - The generated salt.

getRounds(hash)

  • Arguments
    • hash (string) - An encrypted hash.
  • Returns
    • rounds (number) - The number of rounds used to encrypt hash.

hashSync(data, salt)

  • Arguments
    • data (string) - Cleartext data to encrypt.
    • salt (number or string) - The salt used to hash data. If salt is a number, it is passed to genSaltSync() to generate a salt string.
  • Returns
    • hash (string) - The encrypted hash of data using salt.

bcrypt.wasm's People

Contributors

cjihrig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

tuananh uzlopak

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.