Python jenc jpencconverter encryption implementation
Project description
jenc-py
jenc/Markor decrypt/encrypt library
https://github.com/clach04/jenc-py
IMPORTANT before using the optionally encryption features, ensure that it is legal in your country to use the specific encryption ciphers. Some countries have also have restrictions on import, export, and usage see http://www.cryptolaw.org/cls-sum.htm
The aim is to have a pure python (with crypto dependencies) jenc (as used by Markor) decrypt/encrypt library.
Table of contents generated with markdown-toc
Getting Started
Regular install
pip install jenc
Without a source code checkout
Picking up the latest version
pip uninstall jenc; python -m pip install --upgrade git+https://github.com/clach04/jenc.git
From a source code checkout
# pip uninstall jenc
# python -m pip install -r requirements.txt
# TODO requirements_optional.txt
python -m pip install -e .
Examples
Example Encrypt / Decrypt in memory
Test jenc file https://github.com/opensource21/jpencconverter/blob/master/src/test/encrypted/Test3.md.jenc
Test password geheim
from https://github.com/opensource21/jpencconverter/blob/master/src/test/resources/application.properties
import jenc
password = 'geheim' # same password used in demos for Java version https://github.com/opensource21/jpencconverter/tree/master/src/test/encrypted
encrypted_bytes = jenc.encrypt(password, b"Hello World")
plaintext_bytes = jenc.decrypt(password, encrypted_bytes)
jenc file format
There are multiple versions V001 (and the old U001).
TL;DR AES-256-GCM (No Padding), using KDF pbkdf2-hmac-sha512 with 10000 iterations.
File format:
- 4 bytes - define the version.
- nonce bytes - bytes as nonce for cipher depends. The length depends on the version.
- salt bytes - bytes to salt the password. The length depends on the version.
- content bytes - the encrypted content-bytes.
From the original Java code for jpencconverter it appears that strings are converted to/from UTF-8 (i.e. passwords and plaintext).
jenc file format - V001
From Python code:
# note CamelCase to match https://github.com/opensource21/jpencconverter/blob/f65b630ea190e597ff138d9c1ffa9409bb4d56f7/src/main/java/de/stanetz/jpencconverter/cryption/JavaPasswordbasedCryption.java#L229
'keyFactory': 'PBKDF2WithHmacSHA512',
'keyIterationCount': 10000, # this is probably too small/few in 2024
'keyLength': 256,
'keyAlgorithm': 'AES',
'keySaltLength': 64, # in bytes
'cipher': 'AES/GCM/NoPadding',
'nonceLenth': 32, # nonceLenth (sic.) == Nonce Length, i.e. IV length # in bytes
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file jenc-0.0.3.dev1.tar.gz
.
File metadata
- Download URL: jenc-0.0.3.dev1.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1737dcc1d0c9090d85775734b93620250f3c036697b7f4c2cd623496045b30e3 |
|
MD5 | aff7f24ea14e66bd3c8801e41f930e9f |
|
BLAKE2b-256 | 11fef23458e1ee680f0a6d612e9f52faf5fafafc6d6165e41933ed7d7be87e89 |