Skip to main content

Encrypt text with AES256 and create a pdf with QR code that can be printed and stored

Project description

PyAes256

This project aims to encrypt text with AES-256 and put it into a pdf similar to a paperwallet. It is useful for example to encrypt seeds or passwords to a piece of paper and print it. The output is base64 encoded and follows the same scheme that is generated by openssl. Eg. the base64 string starts with "Salt__" followed by 8 bytes of salt. The Rest is the ciphertext.

Disclaimer

Use at your own risk. The author takes no responsibility for any damage, lost funds or similar due to errors in encryption or any other mistakes. Always be cautios when using this tool for important or high value data. Always verify that the decryption script yields the encrypted plaintext. Additionally, crosscheck with openssl if you can decrypt your encrypted data before using it.

Usage

The simplest way is to get the file from pip. pip install pyaes256

Encryption

Then execute it with: pyaes256 encrypt --input "myplaintext"

Then give it a password and confirm. You can optionally specify a --password <mypassword> argument.

Then we will not ask you to confirm it.

To set a different output file use --output targetFile

You can download a single executable standalone exe of the latest release here

Unpack it and run: pyaes256.exe encrypt --input "myplaintext"

As mentioned below it is important to install gtk3 before running the tool! You can download it here https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases

Decryption

pyaes256.exe decrypt --input <base64encryptedcyphertext>

Then just type in your password you set when encrypting.

Getting Started

  1. Install python >3.8

  2. Install pipenv by executing pip install pipenv.

  3. Create a new virtual environment with all dependencies by executing pipenv install.

  4. Important: PyAes256 uses weasyprint to generate the pdf with the encrypted QR Code. In order to make it work on different Operating Systems it is required to install certain libraries, that are needed for rendering..

    For Windows you have to install the GTK+ Libraries. You can download it here https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases

    Pick the gtk3 runtime and install it. After that restart your terminal. Also select the PATH option

    More information at: https://weasyprint.readthedocs.io/en/stable/install.html#step-4-install-the-gtk-libraries

Activating the virtual environment

Before executing any of the commands below, you need to activate the virtual environment. You can do so by executing pipenv shell. Your command prompt should now indicate that you've activated the virtual environment. It can be deactivated by executing exit.

Build single executable

run pyinstaller pyaes256.spec

the executable will be generated in dist folder. Run it with in linux ./dist/pyaes256 encrypt --input "hhhhh"

On Windows: dist/pyaes256.exe encrypt --input "hhhhh"

The paper wallet is generated into the output folder.

Generating encrypted passwords

to encode text with aes256-cbc. Pick any password.

Additional Notes

To verify that this script outputs the same cyphertexts as other tools and it is reproducible you can verify the output with openssl

generate with openssl: echo -n 'mysupersecretseedphrase' | openssl enc -aes-256-cbc -base64 -salt -pbkdf2 -out secretphrase-enc.txt

Then type in your password.

to decode it run: openssl enc -aes-256-cbc -d -base64 -salt -pbkdf2 -in secretphrase-enc.txt

Parameters used for AES-256 encryption

  1. pbkdf2 with 10000 iterations: to derive the pass
  2. pkcf#7 to pad the plaintext to the correct blocksize which must be multiple of 16

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyaes256-0.3.2.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyaes256-0.3.2-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file pyaes256-0.3.2.tar.gz.

File metadata

  • Download URL: pyaes256-0.3.2.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0

File hashes

Hashes for pyaes256-0.3.2.tar.gz
Algorithm Hash digest
SHA256 e45b58c5d8975653586b8f4cb6fa9724902f7dcef782a5fd23c19c59af108def
MD5 38951b1c831685955776d693dff5d294
BLAKE2b-256 9fcd3ba6fc13d7b1d1b6bcacbc79cf1026ca1ecda78b66f89be8768bd9f76676

See more details on using hashes here.

File details

Details for the file pyaes256-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: pyaes256-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0

File hashes

Hashes for pyaes256-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1b325ec43ec19bc71d9d9df3e51ece5fd57513cadce3832209e48f4cc9f1c258
MD5 f66d283dcc8bb26502cffb599e206a57
BLAKE2b-256 5b290886c20a74221747f72c79069f23835876fc167bac8b0030577a230f7019

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page