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

@stellar-fox/cryptops

v1.0.6

Published

Crypto building blocks.

Downloads

7

Readme

cryptops

Crypto building blocks.

npm version npm license GitHub top language GitHub code size GitHub tag

$ npm i @stellar-fox/cryptops

index

foreword

Cryptography is hard. Cryptography is important. Cryptography should be more accessible.

This library aims to tackle the last of the above sencences - it provides coherent API to use in browser as well as in server environment.

All the "heavy lifting" was done by the authors of the following, magnificent projects:

cryptops just wraps and combines some of their parts without adding anything that might lessen the security level.

Go ahead, inspect the source and see for yourself.

documentation

API Reference

play in your browser

RunKit with @stellar-fox/cryptops

  • encrypting text using a passphrase:

    https://runkit.com/xcmats/cryptops.passphraseencrypt

  • decrypting text using a passphrase:

    https://runkit.com/xcmats/cryptops.passphrasedecrypt

use the package

install

$ mkdir playground
$ cd playground/
$ npm init
...
$ npm i @stellar-fox/cryptops
...

Three builds are provided:

  • UMD (in dist directory)
  • CommonJS (in lib directory)
  • ES6 (in es directory)

play in node.js

$ node
>
cryptops = require("@stellar-fox/cryptops")

example use in your code

For utf8-string <-> bytes <-> hex-string <-> b64-string encoding and decoding @xcmats/js-toolbox can be used.

import { passphraseEncrypt } from "@stellar-fox/cryptops"
import { newAddress } from "@stellar-fox/redshift"
import { codec } from "@xcmats/js-toolbox"

let
    myPassphrase = "H0cus P0cus Open Sesam3 4brakadabra",
    myPreciousSecret = newAddress().keypair.secret()

passphraseEncrypt(myPassphrase, codec.stringToBytes(myPreciousSecret))
    .then((ciphertext) => {
        console.log("Now I can sleep peacefully: ", ciphertext)
    })

use the source

$ git clone [email protected]:stellar-fox/cryptops.git
Cloning into 'cryptops'...
$ cd cryptops
$ npm i
$ npm start
Compiling for 'production' ...
Hash: b6a8d4e126caf6f893b8
Version: webpack 4.40.2
Time: 2988ms
Built at: 09/15/2019 5:14:14 PM
      Asset      Size  Chunks             Chunk Names
cryptops.js  24.9 KiB       0  [emitted]  cryptops
Entrypoint cryptops = cryptops.js
[0] external "@xcmats/js-toolbox" 42 bytes {0} [built]
[1] external "sjcl" 42 bytes {0} [built]
[2] external "tweetnacl" 42 bytes {0} [built]
[3] external "@babel/runtime/regenerator" 42 bytes {0} [built]
[4] external "@babel/runtime/helpers/asyncToGenerator" ...
[5] external "crypto-browserify" 42 bytes {0} [built]
[6] ./package.json 4.26 KiB {0} [built]
[7] external "scrypt-js" 42 bytes {0} [built]
[8] ./src/index.js 11.5 KiB {0} [built]

namespace

cryptops
{ random: [Function],
  sha256: [Function],
  salt32: [Function: salt32],
  genKey: [Function: genKey],
  sha512: { [Function] hashLength: 64 },
  salt64: [Function: salt64],
  deriveKey: [Function: deriveKey],
  timestamp: [Function: timestamp],
  genUUID: [Function: genUUID],
  decodeUUID: [Function: decodeUUID],
  salsaNonce: [Function: salsaNonce],
  salsaEncrypt: [Function: salsaEncrypt],
  salsaDecrypt: [Function: salsaDecrypt],
  aesNonce: [Function: aesNonce],
  aesEncrypt: [Function: aesEncrypt],
  aesDecrypt: [Function: aesDecrypt],
  encrypt: { [Function: encrypt] },
  decrypt: { [Function: decrypt] },
  passphraseEncrypt: [Function: passphraseEncrypt],
  passphraseDecrypt: [Function: passphraseDecrypt],
  version: '1.0.6' }

tests

$ npm run test

  uuid test
    ✓ should generate uuid
    ✓ should decode uuid

  passphrase encrypt/decrypt test
    ✓ should generate content (5386ms)
    ✓ should encrypt (2407ms)
    ✓ should have different ciphertexts
    ✓ should decrypt (7258ms)
    ✓ should match content (67ms)
    ✓ should not decrypt with a wrong passphrase (2922ms)


  8 passing (18s)

support

You can support this project via stellar network:

license

cryptops are released under the Apache License, Version 2.0. See the LICENSE for more details.