PR7 AES Java Final
PR7 AES Java Final
PRACTICAL NO.7
Theory:
AES is an Advanced Encryption Standard algorithm. It is a type of symmetric, block cipher encryption and
decryption algorithm. It works with key size 128, 192, and 256 bits. It uses a valid and similar secret key for
both encryption and decryption.
In AES, the block cipher is used. It means that the data to be encrypted is converted into blocks for
encryption. The original data value is encrypted using different bits of padding such as 128, 192, or 256 bits.
Advantages of AES
The encrypted data cannot be decrypted without a valid secret key.AES is the most common security
algorithm used worldwide for various purposes like wireless communication, financial transactions,
encrypted data storage, etc.The companies who want to transfer their data safely and without breaking it can
always use the AES algorithm.
Disadvantages of AES
AES algorithm uses very simple algebraic formulae. Each block is encrypted using a similar kind of
encryption.AES can be difficult to implement with the software.
E&TC/SEM-VII/C&NS/PR07 Page 2
Sipna College of Engineering& Technology, Amravati.
Department of Electronics and Telecommunication Engineering
Program:
#pip install pycryptodome
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
from Crypto.Protocol.KDF import PBKDF2
from Crypto.Util.Padding import pad, unpad
import base64
# Example usage:
password = "SecretPassword"
salt = get_random_bytes(16) # 128-bit salt
# Encryption
encrypted_text = aes_encrypt(key, iv, plaintext)
print("Encrypted:", encrypted_text)
# Decryption
decrypted_text = aes_decrypt(key, iv, encrypted_text)
print("Decrypted:", decrypted_text)
Result:
Original value: AES Encryption
Encrypted: +UhNpr78x1mMAioctezLNV7IYzu1hMfhZBG6Mrei6iI=
E&TC/SEM-VII/C&NS/PR07 Page 3