Skip to content

diegogurpegui/simple-encryption-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple (Symmetric) Encryption Tool

This tool is a simple symmetric encryption tool that allows you to encrypt and decrypt content using a password.
The goal of this project is to have the same encryption/decryption mechamism written in several languages and make them all interoperable.

The encryption algorith used is AES-256-CBC and the key and IV is derived from the password using PBKDF2. You can see the default parameters below.

Usage

All script implementations share the same command signature. The general command structure is:

<executable> [encrypt|decrypt] [options]

Note: Replace <executable> with the appropriate command for your chosen language implementation (see language-specific sections below).

Command Arguments

Action (required)

  • encrypt - Encrypt the input content
  • decrypt - Decrypt the input content

Options

  • --text=<text> or -t <text> - Input text to encrypt/decrypt. Mutually exclusive with --file.
  • --file=<file> or -f <file> - Input file to encrypt/decrypt. Mutually exclusive with --text.
  • --password=<pass> or -p <pass> - Password for encryption/decryption. Optional - if not provided, the tool will prompt for it interactively (recommended for security).
  • --output=<file> or -o <file> - Output file path. If not specified, the result is printed to stdout.
  • --dec-encoding=<enc> - Encoding of the decrypted input/output. Valid values: base64 or utf8 (default: utf8). Note: This option may not be available in all implementations.
  • --help or -h - Show help message

Input behavior: If neither --text nor --file is provided, the tool will prompt for input content interactively.

Important

It is recommended that, even if the examples show it, you DO NOT enter the password in the terminal for security reasons. If you do not enter it, the tool will ask for it interactively.

Language-Specific Implementations

Below are examples for each language implementation. All implementations follow the same command structure described above.

Bash

Command: ./encrypt.sh (or bash encrypt.sh)

Note: Supports both short (-t, -f, -p, -o) and long (--text, --file, --password, --output) option formats. The --dec-encoding option is available.

Node.js (Javascript)

Command: node encrypt.js

Note: Uses long option format (--text, --file, --password, --output). The --dec-encoding option is available.

Python

Command: python encrypt.py (or python3 encrypt.py)

Note: Uses long option format (--text, --file, --password, --output). The --dec-encoding option is not available in this implementation.

PHP

Command: php encrypt.php (or ./encrypt.php if executable)

Note: Uses long option format (--text, --file, --password, --output). The --dec-encoding option is available. Requires PHP 7.0+ (for random_bytes) and PHP 5.5+ (for hash_pbkdf2).

Default Parameters

By default, the tool uses the following parameters:

  • Encryption algorithm: AES-256-CBC
  • Key length: 32 bytes
  • Salt prefix: "Salted__"
    This is used to follow "openssl" standard.
  • PBKDF2 algorithm: sha256
  • PBKDF2 rounds: 10000
  • Encrypted content encoding: base64
  • Unencrypted content encoding: utf8

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.

About

Simple symmetric encryption tool in different languages

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published