You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
My implementation of AES 256-bit encryption written in pure Python! This features the ability to use ECB mode and CBC mode along with various types of input data.
ECB Mode
The simplest of the encryption modes is the Electronic Codebook (ECB) mode.
The message is divided into blocks, and each block is encrypted separately.
# A simple example of encrypting a string with ECB mode!key=0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1faes=AES(key)cyphertext=aes.encrypt('Hello World!')plaintext=aes.decrypt(cyphertext)
CBC Mode
In Cipher Block Chaining (CBC) mode, each block of plaintext is XORed with the previous ciphertext block before being encrypted. This can be denoted as:
Encryption:Ci = Ek(Pi xor C(i-1)) and C0 = IV
Decryption:Pi = Dk(Ci) xor C(i-1) and C0 = IV
# A simple example of encrypting bytes with CBC mode!key=0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fiv=0x000102030405060708090a0b0c0d0e0faes=AES(key,iv)cyphertext=aes.encrypt(b'Hello World!')plaintext=aes.decrypt(cyphertext)