npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pbkdf2-wasm

v0.9.0

Published

WASM implementation of pbkdf2

Downloads

17

Readme

pbkdf2-sha512-wasm

This is a WebAssembly implementation of PBKDF2. However, it has some limitations:

  • Key length cannot be specified, it will always be 64 bytes.
  • While the hash function can be custom, the returned hashes from the function must be 64 bytes since it is only intended to be used with sha512.

This library was created to serve a the base for BIP32 and BIP39, and to work around libauth's implementation of sha512.

This module will return Buffers as its results should a global Buffer object exists. If one doesn't, it will return Uint8Arrays

Usage:

Promise(pbkdf2Instance) instantiatePbkdf2(Object sha512[, Uint8Array binary])

Returns an object specified below.

  • sha512 must be a an object with a hash method. Like this.
  • binary is optional. It must be a Uint8Array containing the WASM binary. If none is specified, it will load the binary provided by this package.

Uint8Array || Buffer pbkdf2Instance.xorStr(Uint8Array buffer, Number value)

Xor's every byte in the buffer by value.


Uint8Array || Buffer pbkdf2Instance.xorStrs(Uint8Array buffer1, Uint8Array buffer2)

Xor's every byte in buffer1 by the corrosponding byte in buffer2. Both arguments must be the same length.


Uint8Array || Buffer pbkdf2Instance.hmacSha512(Uint8Array key, Uint8Array data[, Boolean paranoia])

Returns an HMAC hash

  • key key to hash with.
  • data data to hash with.
  • paranoia zero out the arguments and return data from internal heap. Defaults is true.

Uint8Array || Buffer pbkdf2Instance.pbkdf2Sha512(Uint8Array key, Uint8Array data, Number iterations[, Boolean paranoia])

Returns a PBKDF2 hash

  • key key to hash with.
  • data data to hash with.
  • iterations number of hashing iterations.
  • paranoia zero out the arguments and return data from internal heap. Defaults is true.

pbkdf2Instance.wipeInternalMemory()

Zero out the previous arguments and return data from internal heap. The main purpose of this function is to give the option zero everything out after using the hashing functions consecutively while not clearing the data every single time.


Example:

const cryptowasm = require("@aritz-cracker/cryptowasm");
const {instantiatePbkdf2} = require("pbkdf2-wasm");
const pbkdf2 = await instantiatePbkdf2(await cryptowasm.instantiateSha512());

const data = Buffer.from("aaaaaaa");
const salt = Buffer.from("bbbbbbb");

const hash = pbkdf2.pbkdf2Sha512(salt, data, 2048); // Woohoo! you've got a PBKDF2 hash in WASM!