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

@skiff-org/skiff-crypto

v1.0.3

Published

Cryptographic related functions and helpers

Downloads

1,283

Readme

Logo

skiff-crypto

Welcome! skiff-crypto is a versatile, open-source JavaScript cryptography library specifically designed to provide strong and efficient cryptographic functions for use in NodeJS or in the browser. This package powers cryptography inside Skiff's end-to-end encrypted, privacy-first product suite, including Mail, Pages, Drive, and Calendar applications. For more on Skiff, visit skiff.com.

license npm latest package Follow on Twitter

Features

skiff-crypto brings together a host of cryptographic functionalities:

  • Symmetric Key Cryptography: ChaCha20Poly1305-based symmetric encryption functions.
  • Asymmetric Key Cryptography: TweetNaCl-based asymmetric encryption.
  • Datagram Library: Manage object versions and metadata in an efficient way.
  • Integrity: Support for checksum and data integrity verification.
  • Utilities: A collection of useful utilities for working with cryptographic data, such as utf8 and string conversion.

Getting Started

Prerequisites

  • Node.js 12.0.0 or later, or a modern browser.

Installation

Using npm:

npm install @skiff-org/skiff-crypto

Using Yarn:

yarn add @skiff-org/skiff-crypto

Usage

const skiffCrypto = require('@skiff-org/skiff-crypto');
// or, `import * as skiffCrypto from '@skiff-org/skiff-crypto';`

// Asymmetric encryption example
const plaintext = "Hello, skiff-crypto!";
const keypair = skiffCrypto.generatePublicPrivateKeyPair();
const encrypted = skiffCrypto.stringEncryptAsymmetric(keypair.privateKey, { key: keypair.publicKey }, plaintext);
const decrypted = skiffCrypto.stringDecryptAsymmetric(keypair.privateKey, { key: keypair.publicKey }, encrypted);

console.log('Plaintext:', plaintext);
console.log('Ciphertext:', encrypted);
console.log('Expected to be true:', plaintext === decrypted);

// Symmetric encryption example
const symmetricKey = skiffCrypto.generateSymmetricKey();
// A datagram is used to manage object versions and metadata
const TestDatagram = skiffCrypto.createJSONWrapperDatagram('ddl://test');
const symmetricPlainText = "Hello, skiff-crypto (symmetric encryption)!";
const symmetricEncrypted = skiffCrypto.encryptSymmetric(symmetricPlainText, symmetricKey, TestDatagram);
const symmetricDecrypted = skiffCrypto.decryptSymmetric(symmetricEncrypted, symmetricKey, TestDatagram);
console.log('Symmetric encrypted content', symmetricEncrypted);
console.log('Symmetric decrypted content', symmetricDecrypted);
console.log('Expected to be true:', symmetricPlainText === symmetricDecrypted);

// Hash example
console.log('SHA-512 hash example', skiffCrypto.generateHash('Hello, skiff-crypto!'));

Edit Button

Detailed usage instructions and more examples are available in the API documentation.

Documentation

Comprehensive documentation is available in the documentation site for the repository.

Contributing

Contributions to skiff-crypto are very much appreciated! Please see our Contributing Guidelines for details on how you can contribute.

Security

Cryptography is a sensitive domain. While skiff-crypto has been audited and built using widely-used, audited libraries, we urge you to use this library responsibly. Please have a sound understanding of the underlying principles of cryptography before implementation. Security issues or questions can be sent to [email protected].

License

skiff-crypto is MIT licensed. You're encouraged to use and adapt the code for your projects, given that you respect the original copyright and abide by the license terms.

Contact

For questions, suggestions, or a friendly chat, feel free to contact us at [email protected]. For bug reports or issues, please use our Github Issues page.

Enjoy secure coding!