https://github.com/zheng-bote/qt-cli_file_encryption-decryption
Qt6 C++23 commandline application to encrypt or decrypt a given file on Linux, MacOS, Windows with AES-256 CBC
https://github.com/zheng-bote/qt-cli_file_encryption-decryption
aes-256-cbc cpp23 linux-shell macos-cli qt6 windows-cli
Last synced: 7 months ago
JSON representation
Qt6 C++23 commandline application to encrypt or decrypt a given file on Linux, MacOS, Windows with AES-256 CBC
- Host: GitHub
- URL: https://github.com/zheng-bote/qt-cli_file_encryption-decryption
- Owner: Zheng-Bote
- License: mit
- Created: 2025-03-04T06:18:24.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-03-09T16:09:16.000Z (7 months ago)
- Last Synced: 2025-03-12T08:41:26.785Z (7 months ago)
- Topics: aes-256-cbc, cpp23, linux-shell, macos-cli, qt6, windows-cli
- Language: C++
- Homepage:
- Size: 412 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
file encryption/decryption
File encryption and decryption (shell/commandline)
for Linux, MacOS, Windows
[Report Issue](https://github.com/Zheng-Bote/qt-cli_file_encryption-decryption/issues) [Request Feature](https://github.com/Zheng-Bote/qt-cli_file_encryption-decryption/pulls)
[](https://choosealicense.com/licenses/mit/)
[](https://github.com/Zheng-Bote/qt-cli_file_encryption-decryption/releases)
**Table of Contents**
- [Description](#description)
- [Features](#features)
- [Status](#status)
- [Documentation](#documentation)
- [Usage](#usage)
- [Rules](#rules)
- [Encryption](#encryption)
- [Linux](#linux)
- [Decryption](#decryption)
- [Linux](#linux-1)
- [configuration: dotenv or env](#configuration-dotenv-or-env)
# Description

Qt6 C++23 shell/commandline application to encrypt / decrypt the given file.
- Encryption: AES-256 CBC
- Password: SHA256, between 5 to 32 characters
- initialization vector: MD5## Features
- [x] encrypt/decrypt every readable file (binary-mode, chunk size 4MB)
- [ ] i18n- [x] runs on DOS/Windows (shell/commandline)
- [x] runs on MacOS (cli)
- [x] runs on Linux (cli)
- [ ] runs on iOS
- [ ] runs on Android
- [ ] runs on HarmonyOS
- [ ] supports pipe operator or arguments
- [x] supports arguments and dotenv file- [x] OSS and license
- [x] works as designed
- [ ] no bugs- [x] some more or less usefull Github Actions for GH-repo, GH-pages, GH-wiki, CI/CD-Pipelines
- [ ] Packagemanager
- [x] Buildsystem: CMake
- [x] Installation routine (no Adminstrator rights needed)
- [ ] portable application# Status

[](https://github.com/Zheng-Bote/qt-cli_file_encryption-decryption/releases)



# Documentation
## Usage
```cli
file_encryption-decryption-x86_64 -hcli app to encrypt and decrypt a given file
Usage:
qt-cli_file_encryption-decryption [OPTION...]-s, --source arg to en-/de-crypt. Mandatory: -s | -d
-t, --target arg target . Optional: -t | -d
-p, --pwd arg name of password env variable. Mandatory: -p | -d
-d, --dotenv arg file. Mandatory: -s | -p | -d
-h, --help Print help
```### Rules
**encryption or decryption**
- if sourcefile has not extension `.aes`, sourcefile will be encrypted as targetfile `.aes`
- if sourcefile has extension `.aes`, sourcefile will be decrypted as targetfile `` (without extension `.aes`)> \[!WARNING]
> existing targetfile will be overwritten```mermaid
flowchart TD;
A["path/to/sourcefile"]-. "has not .aes" .->B[[encrypt sourcefile]]
B-- "has --target" -->C["new/path/to/sourcefile.aes"]
B-- "has no --target" -->D["path/to/sourcefile.aes"]A["path/to/sourcefile"]-. "has .aes" .->F[["decrypt sourcefile"]]
F-- "has --target" -->G["new/path/to/sourcefile"]
F-- "has no --target" -->H["path/to/sourcefile"]
```**dotenv-file vs env variables**
The program works with given arguments and/or given dotenv-file.
- if an entry is not defined (dotenv-file, environment variable, argument), the program exit with failure
- a given argument overwrites a dotenv-file entry
- if a given dotenv-file entry is missing, the program looks for the related environment variable```mermaid
flowchart TD;
A["Variable"]-->Dotenv{"is defined in dotenv-file"}
Dotenv-. "Y" .->S1[["set environment variable"]]
S1[["set environment variable"]]-->Attrib{"is defined as attribute"}
Dotenv-. "N" .->Attrib{"is defined as attribute"}
Attrib-. "Y" .->S[["set environment variable"]]
Attrib-. "N" .->V{"get environment variable"}
S-->VV-- "is empty" -->E("EXIT")
V-- "not empty and valid" -->P[["encrypt or decrypt file"]]
```## Encryption
> \[!WARNING]
> don't loose your password. Decryption/Recovery without valid password is impossible!### Linux
**encrypt**
Encrypt `/path/to/sourcefile.xlsx` to `/path/to/sourcefile.xlsx.aes` with environment password-variable
```cli
export my_secret_env_var="my_top_secret_password"
./file_encryption-decryption-x86_64.AppImage --source /path/to/sourcefile.xlsx --pwd my_secret_env_var
```Encrypt `/path/to/sourcefile.xlsx` to `/new/path/to/targetfile.xlsx.aes` with dotenv-file
```cli
./file_encryption-decryption-x86_64.AppImage --source /path/to/sourcefile.xlsx --target /new/path/to/targetfile.xlsx --dotenv /my/configpath/.file_enc-dec
```## Decryption
### Linux
**decrypt**
Decrypt `/path/to/sourcefile.xlsx.aes` to `/path/to/sourcefile.xlsx`
```cli
./file_encryption-decryption-x86_64.AppImage --source /path/to/sourcefile.xlsx.aes ...
```Decrypt `/path/to/sourcefile.xlsx.aes` to `/new/path/to/targetfile.xlsx`
```cli
./file_encryption-decryption-x86_64.AppImage --source /path/to/sourcefile.xlsx.aes --target /new/path/to/targetfile.xlsx ...
```## configuration: dotenv or env
Example dotenv file `.env`
```cli
export my_env_secret="my_top_secret_password"
# => PWD => $my_secret_env_var => my_top_secret_password
``````dotenv
SOURCE_FILE=/inpath/to/file.xlsx # Mandatory or mandatory via argument --source
TARGET_FILE=/outpath/to/file.xlsx # Optional or optional via argument --target
PWD=my_secret_env_var # Mandatory get password from $my_secret_env_var or mandatory via --pwd my_secret_env_var
```````cli
./file_encryption-decryption-x86_64.AppImage --source /path/to/sourcefile.xlsx --pwd my_secret_env_var
```## Test / Performance
**tested on**
- x86_64 Ubuntu 24.04.2 LTS
- Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz with 6 cpu cores
- average SSD storage
- fallocate -l 1G test.img**read / write binary mode of 1 GB file with a chunk size of 4 MB**
| type | val |
| ---- | --------- |
| real | 5m52,734s |
| user | 5m49,905s |
| sys | 0m2,391s |**read / write binary mode of 1 GB file with a chunk size of 16 MB**
| type | val |
| ---- | --------- |
| real | 5m50,753s |
| user | 5m48,691s |
| sys | 0m2,049s |=> so compiled chunk size is 4 MB to give better feedback about the process status.
# Installation
## Linux
- make AppImage executable (eg. `chmod 755 file_encryption-decryption-x86_64.AppImage` )
- execute AppImage## MacOS
- make DiskImage executable (eg. `chmod 755 file_encryption-decryption.dmg`)
- execute / double-click on the `.dmg` file. A window should appear showing the program you are installing and the Applications Folder.
- drag the program into the Applications Folder; macOS will automatically install the software for you.## Windows
_under construction_
# Development
## Dependencies
> \[!NOTE]
> All licenses are therefore Open Source.### CMake
CMake: A Powerful Software Build System
[](https://github.com/conan-io/conan)
[](https://choosealicense.com/licenses/bsd-3-clause/)### QT
> \[!NOTE]
> _QT6 - Community Edition_ >= 6.7The Qt framework contains a comprehensive set of highly intuitive and modularized C++ library classes and is loaded with APIs to simplify your application development. Qt produces highly readable, easily maintainable and reusable code with high runtime performance and small footprint – and it's cross-platform.
[](https://www.qt.io/download-open-source)
[](https://choosealicense.com/licenses/lgpl-3.0/) _see also:_[Obligations of the GPL and LGPL](https://www.qt.io/licensing/open-source-lgpl-obligations)### Qt-AES
Small and portable AES encryption class for Qt. Native support for all key sizes - 128/192/256 bits - ECB, CBC, CFB and OFB modes for all key sizes partial AES-NI support
[](https://github.com/bricke/Qt-AES)
[](https://github.com/bricke/Qt-AES?tab=Unlicense-1-ov-file)### dotenv-cpp
An utility to load environment variables from a .env file
[](https://github.com/laserpants)
[](https://choosealicense.com/licenses/bsd-3-clause)## folder structure
```
.
├── .github
│ ├── actions
│ │ └── doctoc
│ │ ├── README.md
│ │ ├── action.yml
│ │ └── dist
│ │ ├── index.js
│ │ ├── index.js.map
│ │ ├── licenses.txt
│ │ └── sourcemap-register.js
│ └── workflows
│ ├── ghp-call_Readme.yml
│ ├── ghp-create_doctoc.yml
│ ├── ghp-markdown_index.yml
│ ├── repo-actions_docu.yml
│ ├── repo-call_Readme.yml
│ ├── repo-create_doctoc.yml_
│ ├── repo-create_doctoc_md.yml
│ └── repo-create_tree_readme.yml
├── .gitignore
├── LICENSE
├── README.md
├── docs
│ └── dot.env
├── src
│ ├── .gitignore
│ ├── CMakeLists.txt
│ ├── configure
│ │ ├── ClangTidy.cmake
│ │ ├── Doxygen.cmake
│ │ ├── extra_headers
│ │ └── rz_config.h.in
│ ├── includes
│ │ ├── cxxopts.hpp
│ │ ├── dotenv.h
│ │ ├── qaesencryption.cpp
│ │ ├── qaesencryption.h
│ │ ├── rz_config.h
│ │ ├── rz_options.h
│ │ ├── rz_qt-aes.h
│ │ └── rz_snippets.h
│ └── main.cpp
└── tree.bak10 directories, 34 files
```# Authors and License
## MIT License
[](https://choosealicense.com/licenses/mit/)
Copyright (c) 2025 ZHENG Robert
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.## Authors
- [](https://www.github.com/Zheng-Bote)
### Code Contributors

[](https://www.github.com/Zheng-Bote)
:vulcan_salute:
````