easy-doc-crypt
TypeScript icon, indicating that this package has built-in type declarations

2.0.0Β β€’Β PublicΒ β€’Β Published

easy-doc-crypt

This module makes encrypting and decrypting string data with a password easy by leveraging libsodium-wrappers under the hood πŸ‘Œ. It was specifically built to help with encrypting and decrypting data for NeDB πŸ”†.

API

ready()

Wait for the library to be initialized.

generateKey(password: string, salt?: string): { secret: string, salt: string }

Generate a key and salt using a password. If salt is not provided, a new key will be generated each time, so make sure you save the salt! Returns a object with the secret key and the salt. You should never store the secret

encryptDocument(key: string, serializedData: string):{ cipherText: string, header: string }

Encrypt a string with the key. This returns the cipher text and the header. Be sure to store the cipherText with the header or you will not be able to decrypt the data! Returns an object with the cipher text and header.

decryptDocument(key: string, header: string, cipherText: string): string

Decrypt data given a secret key, the header, and the cipher text. It returns a string containing the decrypted data.

Example

Please take a look at the TEST to see how to use it.

/easy-doc-crypt/

    Package Sidebar

    Install

    npm i easy-doc-crypt

    Weekly Downloads

    3

    Version

    2.0.0

    License

    ISC

    Unpacked Size

    15.6 kB

    Total Files

    10

    Last publish

    Collaborators

    • acidleroy