The password based encryption/decryption tool. Allows to encrypt string values or files. Available as a CLI-tool or js/ts package.
Warning
Do not use in the real work-related projects!
The
password-based encryption
does not provide as good protection assymmetric/asymmetric encryption
.
Note
Make sure you have added registry configuration and your GitHub token to
~/.npmrc
file before installation.
echo '//npm.pkg.github.com/:_authToken=$TOKEN
@andr-ii:registry=https://npm.pkg.github.com' >> ~/.npmrc
Then install the package:
# For cli usage
npm i -g @andr-ii/cryl
# For npm package usage
npm i @andr-ii/cryl
# Encrypts "some-string" string and prints result to stdout.
cryl enc -v some-string -p some-password
# Decrypts "RgkFVBoFBwluDK4tRZOjgw==" string and prints result to stdout.
cryl dec -v RgkFVBoFBwluDK4tRZOjgw== -p some-password
# Encrypts file and prints output to "./out.key" file.
cryl enc -f path/to/file.json -p some-password -o ./out.key
# Decrypts file and prints result to stdout.
cryl dec -f ./out.key -p some-password
Also see a help file for additional information.
cryl --help
A NPM package provides encryption and decryption promise functions for string values and files.
For string values functions: If result is successful - string value will be returned.
If error occurred during execution - it will be thrown.
import { encrypt } from '@andr-ii/cryl';
const encryptedString = await encrypt('some-string', 'password');
console.log(encryptedString); // 'szCiRKg7LwIn27uBOFpBaQ=='
import { encrypt } from '@andr-ii/cryl';
await encrypt('some-string', 'password', 'encrypted.key'); // writes result to 'encrypted.key' file;
import { encryptFile } from '@andr-ii/cryl';
const encryptedFile = await encryptFile('./package.json', 'password');
console.log(encryptedFile); // 'encrypted package.json file'
import { encryptFile } from '@andr-ii/cryl';
await encryptFile('./package.json', 'password', 'encrypted.key'); // writes result to 'encrypted.key' file;
import { decrypt } from '@andr-ii/cryl';
const decryptedValue = await decrypt('szCiRKg7LwIn27uBOFpBaQ==', 'password');
console.log(decryptedValue); // 'some-string'
import { decrypt } from '@andr-ii/cryl';
await decrypt('szCiRKg7LwIn27uBOFpBaQ==', 'password', 'result.log'); // writes result to 'result.log' file;
import { decryptFile } from '@andr-ii/cryl';
const decryptedFile = await decryptFile('./encrypted.key', 'password');
console.log(decryptedFile); // 'decrypted file'
import { decryptFile } from '@andr-ii/cryl';
await decryptFile('./encrypted.key', 'password', 'result.log'); // writes result to 'result.log' file;