2.1.0 • Published 5 months ago
file-cipher v2.1.0
file-cipher
A simple file encryption and decryption utility for Node.js
Installation
npm install file-cipher
Usage
import { encrypt, decrypt } from "file-cipher";
// Encrypt from a file path
const encryptedFromFile = encrypt("./sensitive.txt", "mySecurePassword");
// Encrypt from a buffer
const fileBuffer = fs.readFileSync("./sensitive.txt");
const encryptedFromBuffer = encrypt(fileBuffer, "mySecurePassword");
// Decrypt from a file path
const decryptedFromFile = decrypt("./encrypted.bin", "mySecurePassword");
// Decrypt from a buffer
const encryptedBuffer = fs.readFileSync("./encrypted.bin");
const decryptedFromBuffer = decrypt(encryptedBuffer, "mySecurePassword");
API
encrypt(input: string | Buffer, password: string): Buffer
decrypt(input: string | Buffer, password: string): Buffer