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

@10dimen/crypto-toolkit

v1.0.4

Published

**CryptoToolkit** is a comprehensive encryption and data security library designed for web applications. It provides easy-to-use functions for encrypting and decrypting data, as well as managing encryption keys. With support for **AES-GCM** and **RSA-OAEP

Downloads

35

Readme

CryptoToolkit

CryptoToolkit is a powerful and flexible encryption library designed for modern web applications. It provides comprehensive utilities for data encryption, decryption, and key management, supporting AES-GCM and RSA-OAEP algorithms. Additionally, it includes functionalities for hashing data using SHA-512.

Features

  • Key Management: Easily generate, export, and import public and private keys.
  • Encryption and Decryption: Securely encrypt and decrypt data with advanced algorithms.
  • Data Storage: Store encrypted data in localStorage or sessionStorage.
  • Hashing: Compute SHA-512 hashes of data for integrity checks and more.
  • User-Friendly API: Integrate encryption features seamlessly into your applications.

Installation

To install CryptoToolkit, you can use npm or yarn:

npm install @10dimen/crypto-toolkit

Or with yarn:

yarn add @10dimen/crypto-toolkit

Usage

Encryption and Decryption

Encrypt and store data:

import { CryptoUtils } from '@10dimen/crypto-toolkit';

// Encrypt and store data in localStorage
await CryptoUtils.encryptAndStore('myKey', 'mySecretData');

Decrypt data from storage:

import { CryptoUtils } from '@10dimen/crypto-toolkit';

// Retrieve and decrypt data from localStorage
const decryptedData = await CryptoUtils.decryptFromStorage('myKey');
console.log(decryptedData); // Output: 'mySecretData'

Key Management

Generate a new key pair:

const keys = await CryptoUtils.generateKey();
console.log(keys);

Export and import keys:

// Export public key
const publicKey = await CryptoUtils.exportPublicKey();
console.log(publicKey);

// Import public key
const importedPublicKey = await CryptoUtils.importPublicKey(publicKey);

Hashing

Hash data using SHA-512:

const hashedData = await CryptoUtils.hashSHA512('myData');
console.log(hashedData);

Note: MD5 hashing is not supported by the Web Crypto API and is not included in this library. For MD5 hashing, consider using additional libraries.

API Reference

CryptoUtils.encrypt(data: string | ArrayBuffer): Promise<ArrayBuffer>

Encrypts the provided data using RSA-OAEP.

  • data: The data to encrypt (can be a string or an ArrayBuffer).

CryptoUtils.decrypt(encryptedData: ArrayBuffer): Promise<string>

Decrypts the provided data using RSA-OAEP.

  • encryptedData: The encrypted data to decrypt (must be an ArrayBuffer).

CryptoUtils.encryptAndStore(key: string, data: string, storage: string = 'localStorage'): Promise<void>

Encrypts the data and stores it in the specified storage.

  • key: The key under which the data will be stored.
  • data: The data to encrypt and store.
  • storage: Storage type, either 'localStorage' or 'sessionStorage'.

CryptoUtils.decryptFromStorage(key: string, storage: string = 'localStorage'): Promise<string | null>

Retrieves and decrypts data from the specified storage.

  • key: The key under which the data is stored.
  • storage: Storage type, either 'localStorage' or 'sessionStorage'.

CryptoUtils.hashSHA512(data: string): Promise<string>

Hashes the provided data using SHA-512.

  • data: The data to hash.

Contributing

We welcome contributions! To contribute:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/YourFeature).
  3. Make your changes.
  4. Commit your changes (git commit -am 'Add new feature').
  5. Push to the branch (git push origin feature/YourFeature).
  6. Open a Pull Request.

Please refer to the CONTRIBUTING.md for more details.

License

This project is licensed under the MIT License - see the LICENSE file for details.