Skip to main content

No project description provided

Project description

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)

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

pycryptosimple_aes-1.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

pycryptosimple_aes-1.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file pycryptosimple_aes-1.1.tar.gz.

File metadata

  • Download URL: pycryptosimple_aes-1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pycryptosimple_aes-1.1.tar.gz
Algorithm Hash digest
SHA256 5fe7463bac38a757a52bc86b59df948f9e5267ab15c8fafba512135096910b92
MD5 e902e607124f851027cb7a1f4a8aa0d5
BLAKE2b-256 8bf68ff5ce3a9f52c51b56695837e9705973207329ffcd89ab405f5a38ad2497

See more details on using hashes here.

File details

Details for the file pycryptosimple_aes-1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pycryptosimple_aes-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b69cf5f50c0f2aa727908c1bef0c1ec953b1eff505da07923469c756f9609516
MD5 471a99c4601ce0c9049c3ac54ca57298
BLAKE2b-256 5529d5a9689d70b14da3a73c5cfb6f4f025db444877e8054ddf867384c7cdf2d

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