Thanks to visit codestin.com
Credit goes to github.com

Skip to content

JuanBindez/einar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Einar

PyPI - Downloads PyPI - License GitHub Tag

Python3 library that implements AES-128, AES-192, AES-256 encryption in ECB and CBC modes.

Install

pip install einar

Quickstart

from einar import AES

key = b''  # The key can be any size; it will be padded or truncated to the required length.

# AES-256 CBC example
iv = b'1234567890abcdef'  # Required for CBC mode, must be 16 bytes
cipher = AES(key, keyLen=256, mode="CBC", iv=iv)

message = b'Secret message to encrypt'

Encrypt

ciphertext = cipher.encrypt(message)
print(f"Ciphertext (hex): {ciphertext.hex()}")

Decrypt

original_text = cipher.decrypt(ciphertext)
print(f"Original text: {original_text.decode('utf-8')}")

Modes

ECB (Electronic Codebook)

cipher = AES(key, keyLen=128, mode="ECB")
ciphertext = cipher.encrypt(message)
original_text = cipher.decrypt(ciphertext)

CBC (Cipher Block Chaining)

iv = b'1234567890abcdef'  # 16 bytes
cipher = AES(key, keyLen=256, mode="CBC", iv=iv)
ciphertext = cipher.encrypt(message)
original_text = cipher.decrypt(ciphertext)

CLI

Einar includes a command-line interface for encryption and decryption:

einar -e "Secret message" -kl 256 -m CBC

License

Distributed under GPL v2 or later.

Author

Juan

About

Python3 library that implements AES-128, AES-192, AES-256 encryption in ECB and CBC modes.

Resources

License

Stars

Watchers

Forks

Packages

No packages published