next-edge-crypto
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

next-edge-crypto

next-edge-crypto is a JavaScript library crafted to provide sophisticated encryption and decryption functionalities using the WebCrypto API. This library is specially designed for edge runtime environments, such as those in Next.js or Vercel, serving as a contemporary alternative to Node.js's native crypto module.

Features

  • WebCrypto API Utilization: Employs the WebCrypto API for encryption and decryption, aligning with contemporary web standards.
  • Edge Runtime Optimization: Tailored for peak performance in edge runtime environments.
  • Scalable Architecture: Built with a vision to incorporate additional encryption algorithms and broaden functionalities in future updates.

Installation

To integrate next-edge-crypto into your project, use the following command:

npm install next-edge-crypto
# or
yarn add next-edge-crypto

Usage

To use the library, start by importing the necessary functions:

import { encrypt, decrypt } from 'next-edge-crypto';

or you can import like this:

import * as crypto from 'next-edge-crypto';

Then, you can use the functions as follows:

Encryption

Encrypt your data as follows:

const encryptedData = await encrypt("your data here", "your base64 encoded key");
console.log(encryptedData); // Outputs encrypted data in hex format

Decryption

Decrypt your data as follows:

const decryptedData = await decrypt("your encrypted data here", "your base64 encoded key");
console.log(decryptedData); // Outputs the original data

API reference

  • encrypt(data: string, key: string): Promise<string>: Encrypts the input string using the AES-CBC algorithm and returns the encrypted data in hex format.
  • decrypt(data: string, key: string): Promise<string>: Decrypts the input string using the AES-CBC algorithm and returns the original data.

Contributing

We welcome contributions to next-edge-crypto, particularly those that add new encryption algorithms and expand functionality. Feel free to fork the repository, apply your enhancements, and submit a pull request.

License

This project is licensed under the MIT License. See LICENSE for more details.

Readme

Keywords

none

Package Sidebar

Install

npm i next-edge-crypto

Weekly Downloads

2

Version

0.1.0

License

MIT

Unpacked Size

30.3 kB

Total Files

6

Last publish

Collaborators

  • knrs