Simple AES
Find more information about this library HERE
An easy way to use the aes CBC mode of pycryptodome. To use this library just type:
pip install pycryptosimple-aes
Code examples
Automated key generation:
from pycryptosimple_aes import *
key = keyGenerator()
IV = ivGenerator()
aes = simpleAES(key, IV)
text = "This is a test".encode()
ciphertext = aes.encrypt(text)
plaintext = aes.decrypt(ciphertext)
print("This is the ciphertext:", ciphertext)
print("This is the plaintext:", plaintext.decode())
Setup custom keys:
from pycryptosimple_aes import *
key = "This is a key".encode()
iv = "This is an IV".encode()
salt = "This is a salt".encode()
# The hash option will hash the key with the sha256 algorithm
# and the IV with the md5 algorithm with the salt to
# prevent brute force attacks
aes = simpleAES(key, iv, hash=True, salt=salt)
text = "This is a text".encode()
ciphertext = aes.encrypt(text)
plaintext = aes.decrypt(ciphertext)
print("ciphertext:", ciphertext)
print("plaintext:", plaintext.decode())
Store the key to a file:
from pycryptosimple_aes import *
key = keyGenerator()
IV = ivGenerator()
aes = simpleAES(key, IV)
path = "key.key"
aes.extractKey(path)
Store the key to an encrypted file:
from pycryptosimple_aes import *
key = keyGenerator()
iv = ivGenerator()
aes = simpleAES(key, iv)
key2 = "abcde".encode()
iv2 = "12345".encode()
salt = "qwerty".encode()
aes2 = simpleAES(key, iv , hash=True, salt=salt)
path="encryptedKey.key"
#It will encrypt the file with the 'aes2' object.
aes.extractEncryptedKey(aes2, path)
Load the key from file:
from pycryptosimple_aes import *
path = "key.key"
data = loadKeyFromFile(path)
key = data[0]
IV = data[1]
# When you load a key from file do not set the
# hash value to True or use the salt option,
# because in the file are stored the hashed values and not
# the original keywords.
aes = simpleAES(key, IV)
Load the key from encrypted file:
key = "abcde".encode()
iv = "12345".encode()
salt = "qwerty".encode()
aes = simpleAES(key, iv, hash=True, salt=salt)
path="encryptedKey.key"
data = loadKeyFromEncryptedFile(aes, path)
key = data[0]
iv = data[1]
aes = simpleAES(key, iv)
Metadata
Release files for pycryptosimple-aes 1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pycryptosimple_aes-1.1.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pycryptosimple_aes-1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.0 kB
Release files / pycryptosimple_aes-1.1.tar.gz
| Download URL | pycryptosimple_aes-1.1.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5fe7463bac38a757a52bc86b59df948f9e5267ab15c8fafba512135096910b92
|
|
BLAKE2b-256 checksum How to use checksums |
8bf68ff5ce3a9f52c51b56695837e9705973207329ffcd89ab405f5a38ad2497
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Release files / pycryptosimple_aes-1.1-py3-none-any.whl
| Download URL | pycryptosimple_aes-1.1-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b69cf5f50c0f2aa727908c1bef0c1ec953b1eff505da07923469c756f9609516
|
|
BLAKE2b-256 checksum How to use checksums |
5529d5a9689d70b14da3a73c5cfb6f4f025db444877e8054ddf867384c7cdf2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|