Package Exports
- cryptify
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cryptify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
cryptify
File-based encryption (FBE) with Node.js
CLI
Installation
Yarn or npm
yarn global add cryptify
$ npm i -g cryptify
Usage
Adheres to http://docopt.org/
$ cryptify <file>... (-e|-d) -p <password> [options]
Options
Short | Long | Description | Default | Required |
---|---|---|---|---|
-e | --encrypt | Encrypt file(s) | Yes | |
-d | --decrypt | decrypt file(s) | Yes | |
-p | --password | Cryptographic key | Yes | |
-c | --cipher | Cipher algorithm | aes-256-cbc-hmac-sha256 | No |
-n | --encoding | Character encoding of returned file(s) | utf8 | No |
-l | --list | List available cipher algorithms | No | |
-h | --help | Show help menu | No | |
-v | --version | Show version | No |
Encrypt a file with a password:
$ cryptify ./configuration.props -e -p mySecretKey
Encrypt some files with a custom cipher:
$ cryptify ./foo.json ./bar.json ./baz.json -e -p mySecretKey -c aes-256-cbc
When decrypting, be sure to use the same cipher:
$ cryptify ./foo.json ./bar.json ./baz.json -d -p mySecretKey -c aes-256-cbc
Show help
$ cryptify --help Cryptify v2.2.8 File-based Encryption Utility https://www.npmjs.com/package/cryptify Implements Node.js Crypto (https://nodejs.org/api/crypto.html) Usage: cryptify <file>... -p <password> (-e|-d) [options] cryptify ./configuration.props -p mySecretKey -e -c aes-256-cbc cryptify ./foo.json ./bar.json -p mySecretKey --decrypt cryptify --version Required Commands: -e --encrypt Encrypt the file(s) -d --decrypt Decrypt the file(s) Required Arguments: -p --password Cryptographic key Optional Arguments: -c --cipher <algorithm> Cipher algorithm (Default: aes-256-cbc-hmac-sha256) -n --encoding <encoding> Character encoding of returned file(s) (Default: utf8) -l --list List available ciphers -h --help Show this menu -v --version Show version Required Password Wrapping: Bash single-quotes Command Prompt double-quotes PowerShell single-quotes Password Requirements: 1) Must contain at least 8 characters 2) Must contain at least 1 special character 3) Must contain at least 1 numeric character 4) Must contain a combination of uppercase and lowercase
Module
Installation
Yarn or npm
yarn add cryptify
$ npm i -S cryptify
CommonJS
const Cryptify = require('cryptify/lib/cryptify').default;
ES2015
import Cryptify from 'cryptify/lib/cryptify';
Constructor
new Cryptify(files, password, cipher, encoding)
Encrypt / Decrypt
try {
const instance = new Cryptify('./example.txt', process.env.ENV_SECRET_KEY);
instance
.encrypt()
.then((files) => {
// do stuff
instance
.decrypt()
.then((files) => {
// do stuff
});
});
} catch (error) {
console.error(error.message);
}
Decrypt / Encrypt
try {
const instance = new Cryptify(['./foo.props', './bar.json'], process.env.ENV_SECRET_KEY);
instance
.decrypt()
.then((files) => {
// do stuff
instance
.encrypt()
.then((files) => {
// do stuff
});
});
} catch (error) {
console.error(error.message);
}
Password Requirements
- Must contain at least 8 characters
- Must contain at least 1 special character
- Must contain at least 1 numeric character
- Must contain a combination of uppercase and lowercase
Recommendations
Strongly consider clearing your shell's session history of any sensitive information.
Bash
Bash writes the current session history to disk (~/.bash_history
) at the end of the session.
Tactical Approach: Clear a specific entry in the current session
$ history 666 cryptify --help 667 cryptify ./myfile.txt -e -p mySecretKey $ history -d 667 $ history -w
Blunt Approach: Clear the entire current session history (in memory)
$ history -c
Nuclear Approach: Clear current and existing session history (in memory, and on disk)
$ rm $HISTFILE $ history -c $ exit (open shell) $ cat $HISTFILE exit
Windows Command Prompt
Windows does not store history between command prompt sessions.
However, for safety, consider decreasing the
Buffer Size
andNumber of Buffers
in the Properties menu before use.Per this configuration, Windows will only store the last command in the buffer.
Once work with
cryptify
is complete, close the command prompt:C:\Users\[user]> cryptify ./myfile.txt -e -p mySecretKey C:\Users\[user]> exit
Windows PowerShell
PowerShell's
Clear-History
command doesn't seem to work as advertised, which is designed to clear the current session's history.However, deleting PowerShell's history file does do the trick.
PS C:\Users\[user]> cryptify ./myfile.txt -e -p mySecretKey PS C:\Users\[user]> del (Get-PSReadlineOption).HistorySavePath PS C:\Users\[user]> exit