1.0.0 • Published 5 years ago

bxor-crypt v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

bxor-crypt

bxor-crypt is a Node.JS library that provides a simple but secure API for encrypting and decrypting string and files. It supports every type of file, either a plain text one and a binary file. The encrypted result is a base64 string that can be stored safely everywhere.

Installation

bxor-crypt is a npm module. It can be installed with this command:

$ npm install bxor-crypt

Usage

A simple example on encrypting a string and its expected output:

const bx = require("bxor-crypt");
console.log(bx.encrypt("ABCdefGHIjkl", "password"));
// Will output "jpyPqK22ipOGtKeg"
console.log(bx.decrypt("jpyPqK22ipOGtKeg", "password"));
// Will output "ABCdefGHIjkl"

Headers

To check if the string was decrypted succesfully, bxor-crypt implements headers. When encrypting, a header can be specified. It will be checked later during decryption. If the header isn't present or is incorrect, it will raise an error. This is useful for checking the integrity and if the provided password is correct.

Methods

encrypt(str, salt, header, xrn)

  • str: The string to encrypt
  • salt: The "password" or salt used to encrypt the string
  • header: The header to use. Leave empty to not use any
  • xrn: A value used during encryption to apply the bitwise XOR. Default to 191, but can be set to any

decrypt(str, salt, header, xrn)

  • str: The string to decrypt
  • salt: The "password" or salt used to decrypt the string
  • header: The header to check. Leave empty to not check any
  • xrn: A value used during decryption to apply the bitwise XOR

encryptFile(input, output, salt, header, xrn)

  • input: A file or a path to a file. Represents the file that will be encrypted
  • output: The file or the path to the file where the encrypted file will be saved
  • salt: The "password" or salt used to encrypt the file
  • header: The header to use. Leave empty to not use any
  • xrn: A value used during encryption to apply the bitwise XOR

decryptFile(input, output, salt, header, xrn)

  • input: A file or a path to a file. Represents the file that will be decrypted
  • output: The file or the path to the file where the decrypted file will be saved
  • salt: The "password" or salt used to decrypt the file
  • header: The header to check. Leave empty to not check any
  • xrn: A value used during decryption to apply the bitwise XOR

License

This project is licensed under the MIT license. It can be checked online here or in the LICENSE file in this repository.

Contributing

Contributing to this project is welcome. If you find any bug, want to improve the project or just want to give feedback, do it at the main project repo. Every help is welcome and appreciated.

1.0.0

5 years ago