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

keycipher

v1.0.0

Published

A utility package for encrypting and decrypting text using AES-GCM with a secret key.

Downloads

12

Readme

KeyCipher

keycipher is a utility package for encrypting and decrypting text using AES-GCM with a secret key. It leverages the WebCrypto API to provide secure encryption and decryption functionalities.

Installation

To install the package, run the following command:

npm install keycipher

Usage

Here’s a brief guide on how to use the keycipher package.

Importing the Package

const { encryptData, decryptData } = require('keycipher');

Encrypting Data

To encrypt a piece of text, use the encryptData function. You need to provide the plaintext and a key string.

const { encryptData } = require('keycipher');

(async () => {
    try {
        const keyString = 'your-secret-key'; // Replace with your key
        const plainText = 'This is a secret message'; // Replace with your text

        const encryptedData = await encryptData(plainText, keyString);

        console.log('Encrypted Data:', encryptedData);
    } catch (error) {
        console.error('Encryption Error:', error);
    }
})();

Decrypting Data

To decrypt data, use the decryptData function. You need to provide the encrypted data and the same key string used for encryption.

const { decryptData } = require('keycipher');

(async () => {
    try {
        const keyString = 'your-secret-key'; // Replace with your key
        const encryptedData = {
            iv: '...your IV...',
            cipherText: '...your cipherText...',
            tag: '...your tag...'
        }; // Replace with your generated encryption object

        const decryptedText = await decryptData(encryptedData, keyString);

        console.log('Decrypted Text:', decryptedText);
    } catch (error) {
        console.error('Decryption Error:', error);
    }
})();

API

encryptData(plainText, key)

Encrypts the given plaintext using the provided key string.

  • Arguments:
    • plainText (String): The text to be encrypted.
    • key (String): The key used for encryption.
  • Returns: An object containing iv, cipherText and tag.

decryptData(encryptedData, key)

Decrypts the given encrypted data using the provided key string.

  • Arguments:

    • encryptedData (Object): The encrypted data object, which includes iv, cipherText and tag.
    • key (String): The key used for decryption.
  • Returns: The decrypted text.

About the Author

keycipher is created by Parth Dudhatra (imParth), a passionate software engineer, developer advocate, and content creator known for his contributions to the tech community. He is passionate about frontend development, Python programming, open-source software, and sharing knowledge with others.

Parth is active on various social media platforms, where he shares insights, tutorials, and tips related to programming, web development, and software engineering. Parth's dedication to sharing his expertise and fostering a supportive environment for developers has earned him recognition and respect within the tech community.

Connect with Parth Dudhatra on social media:

If you have any questions, feedback, or suggestions, feel free to reach out to me on any platform!

License

This project is licensed under the ISC License.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.

Issues

If you encounter any issues, please report them on the issues page.