@ignisia/encryption
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

@Ignisia/Encryption

Encryption utilities for @ignisia/securedb and other package related.

Requirements

Installation

bun add @ignisia/encryption

Usage

import {
  encryptFile,
  decryptFile,
  encryptData,
  decryptData,
} from '@ignisia/encryption';

// Encrypt a file
await encryptFile({
  input: 'file.txt',
  output: 'file.txt.enc',
  password: 'password',
  // Add salt for extra security, optional
  salt: 'salt',
});

// Decrypt a file
await decryptFile({
  input: 'file.txt.enc',
  output: 'file.txt',
  password: 'password',
  // Add salt for extra security, optional
  // Salt should be the same as the one used to encrypt the file
  salt: 'salt',
});

// Encrypt data
const encryptedData = await encryptData({
  data: 'data',
  password: 'password',
  // Add salt for extra security, optional
  salt: 'salt',
});
// ^ it will return the encrypted data as a string base64 encoded and the iv as a string base64 encoded

// Decrypt data
const decryptedData = await decryptData({
  data: 'data',
  password: 'password',
  // The iv should be the same as the one used to encrypt the data
  iv: 'iv',
  // Add salt for extra security, optional
  // Salt should be the same as the one used to encrypt the data
  salt: 'salt',
});

Some of the functions is not covered in the usage example above

Readme

Keywords

none

Package Sidebar

Install

npm i @ignisia/encryption

Weekly Downloads

9

Version

0.1.2

License

none

Unpacked Size

7.64 kB

Total Files

12

Last publish

Collaborators

  • krsbx