Skip to content

`next-edge-crypto` uses the WebCrypto API, optimized for edge runtime environments like Next.js and Vercel. Ideal for projects requiring reliable crypto operations outside of Node.js' native capabilities, with a scalable architecture ready for future enhancements.

License

NorasTech/next-edge-crypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

`next-edge-crypto` uses the WebCrypto API, optimized for edge runtime environments like Next.js and Vercel. Ideal for projects requiring reliable crypto operations outside of Node.js' native capabilities, with a scalable architecture ready for future enhancements.

Topics

Resources

License

Stars

Watchers

Forks