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
A dead simple file-based encyrption (FBE) utitily for Node.js.
❤️ CLI or module-based usage
❤️ Implements Node.js crypto
❤️ Zero dependencies
❤️ Licensed with GPLv2
Table of Contents
CLI
Installation
$ npm i -g cryptify
Usage
Adheres to http://docopt.org/
$ cryptify <file>... (-e|-d) -p <password> [options]
Arguments
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
Decrypt some files with a custom cipher
Omit the cipher if the default was used
$ cryptify ./foo.json ./bar.json ./baz.json -d -p mySecretKey -c aes-256-cbc
Show help
$ cryptify --help
Cryptify v3.0.2 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
$ npm i -S cryptify
CommonJS
const Cryptify = require('cryptify');
ES2015
import Cryptify from 'cryptify';
Constructor
new Cryptify(files, password, cipher, encoding)
Encrypt / Decrypt
import Cryptify from 'cryptify';
const filePath = './example.txt';
const password = process.env.ENV_SECRET_KEY;
try {
const instance = new Cryptify(filePath, password);
instance
.encrypt()
.then(files => { /* Do stuff */ })
.then(() => instance.decrypt())
.then(files => { /* Do stuff */ })
} catch (error) {
console.error(error.message);
}
Decrypt / Encrypt
import Cryptify from 'cryptify';
const filePaths = ['./foo.props', './bar.json'];
const password = process.env.ENV_SECRET_KEY;
try {
const instance = new Cryptify(filePaths, password);
instance
.decrypt()
.then(files => { /* Do stuff */ })
.then(() => 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