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

libsodium-tweetnacl-wrappers

v1.0.1

Published

Lib Sodium wrapped in TweetNacl api

Downloads

12

Readme

crypto_hash function

  • nacl.lowlevel.crypto_hash
const nacl = require("./dist/modules-sumo/libsodium-tweetnacl-wrappers")
x = Uint8Array.from("uE8PKeSYFIorw8ojOk4Cg7et0s4WSxf5WpjOORascdLW2wQuYvGoLDR7zM9USNh5")
nacl.lowlevel.crypto_hash(x)
  • should return 0 and change the value of x to the new encrypted value

box.before function

  • Returns a precomputed shared key which can be used in nacl.box.after and nacl.box.open.after
const nacl = require("./dist/modules-sumo/libsodium-tweetnacl-wrappers")
x = Uint8Array.from("T6Mjk3c65EI2C09F6jlr1fibgaqgC1eT")
y = Uint8Array.from("T6Mjk3c65EI2C09F6jlr1fibgaqgC1eT")
nacl.box.before(x, y)
  • should return a new array with 32U length

box.keyPair

  • Generates a new random key pair for box and returns it as an object with publicKey and secretKey members
const nacl = require("./dist/modules-sumo/libsodium-tweetnacl-wrappers")
nacl.box.keyPair()
  • should return a new array with publicKey and secretKey each with 32U length

box.keyPair.fromSecretKey

  • Returns a key pair for box with public key corresponding to the given secret key.
const nacl = require("./dist/modules-sumo/libsodium-tweetnacl-wrappers")
secret = (nacl.box.keyPair()).secretKey
nacl.box.keyPair.fromSecretKey(secret)
  • should return a new array with publicKey and secretKey each with 32U length

sign.keyPair

  • Generates new random key pair for signing and returns it as an object with publicKey and secretKey members
const nacl = require("./dist/modules-sumo/libsodium-tweetnacl-wrappers")
nacl.sign.keyPair()
  • should return a new array with publicKey 32U length and secretKey 64U length

sign.detached function

  • nacl.sign.detached
const nacl = require("./dist/modules-sumo/libsodium-tweetnacl-wrappers")
message = Uint8Array.from("T6Mjk3c65EI2C09F6jlr1fibgaqgC1eT")
key = Uint8Array.from("T6Mjk3c65EI2C09F6jlr1fibgaqgC1eTT6Mjk3c65EI2C09F6jlr1fibgaqgC1eT")
nacl.sign.detached(message, key)
  • should return the new encrypted value with 32U length (in tweetnacl the length is 64 but in this case it's ok as at verification is also in sodium)

sign.detached.verify function

  • nacl.sign.detached.verify
const nacl = require("./dist/modules-sumo/libsodium-tweetnacl-wrappers")
message = Uint8Array.from("T6Mjk3c65EI2C09F6jlr1fibgaqgC1eT")
key = Uint8Array.from("T6Mjk3c65EI2C09F6jlr1fibgaqgC1eTT6Mjk3c65EI2C09F6jlr1fibgaqgC1eT")
token = nacl.sign.detached(message, key)
nacl.sign.detached.verify(message, token,  key)
  • should return true, as the message is verified with the right token

sign.keyPair.fromSeed function

  • nacl.sign.keyPair.fromSeed
const nacl = require("./dist/modules-sumo/libsodium-tweetnacl-wrappers")
seed = Uint8Array.from("T6Mjk3c65EI2C09F6jlr1fibgaqgC1eT")
nacl.sign.keyPair.fromSeed(seed)
  • should return a new array with publicKey 32U length and secretKey 64U length

notes

  • testing will not working unless npm i passes (best to test in a unix, mac os is problematic) see node-sodium installation for instructions
  • all returned values should be of type Uint8Array
  • all sodium functions receive a buffer, the workaround is to convert the buffers to Uint8Array pass it to sodium and change the original arrays by reference copy