This Simple Python Trick Encrypts Text Like a Cybersecurity Pro! 🔐💻

Published: 27 March 2025
on channel: gadget_Saavy
7
0

This Simple Python Trick Encrypts Text Like a Cybersecurity Pro! 🔐💻

Want to learn how to encrypt text like a pro? In this tutorial, I’ll show you how to use Python and the PyCryptodome library to encrypt messages using AES encryption in ECB mode. We’ll generate a secure key from SHA-256 hashing** and pad our plaintext to fit the encryption block size.

What You’ll Learn:
✅ How to hash a key using SHA-256
✅ How to encrypt text with AES in Python
✅ Why padding is necessary for AES encryption
✅ How to convert encrypted data to a hex format

📜 Code Used in This Video:
from Crypto.Cipher import AES
from Crypto.Hash import SHA256
from Crypto.Util.Padding import pad

input_string = "PittsburghSteelersMostSuperBowls"

hash_object = SHA256.new(data=input_string.encode())
key = hash_object.digest()

cipher = AES.new(key, AES.MODE_ECB)

plaintext = "imma bo$$"

plaintext_padded = pad(plaintext.encode(), AES.block_size)

ciphertext = cipher.encrypt(plaintext_padded)

print("Ciphertext:", ciphertext.hex())

!!!!! The 32byte input string MUST BE 32bytes. Do not change it if you
don't understand what that means.

🔔 Don’t forget to *LIKE* 👍, *SUBSCRIBE* 🔴, and hit the *NOTIFICATION BELL* 🔔 so you don’t miss future tutorials!

#Python #CyberSecurity #Encryption #AES #PythonTutorial


On this page of the site you can watch the video online This Simple Python Trick Encrypts Text Like a Cybersecurity Pro! 🔐💻 with a duration of hours minute second in good quality, which was uploaded by the user gadget_Saavy 27 March 2025, share the link with friends and acquaintances, this video has already been watched 7 times on youtube and it was liked by 0 viewers. Enjoy your viewing!