Encryption program in Python 🔐

Published: 17 November 2022
on channel: Bro Code
121,549
3.4k

#python #course #tutorial

import random
import string

chars = " " + string.punctuation + string.digits + string.ascii_letters
chars = list(chars)
key = chars.copy()

random.shuffle(key)

#ENCRYPT
plain_text = input("Enter a message to encrypt: ")
cipher_text = ""

for letter in plain_text:
index = chars.index(letter)
cipher_text += key[index]

print(f"original message : {plain_text}")
print(f"encrypted message: {cipher_text}")

#DECRYPT
cipher_text = input("Enter a message to encrypt: ")
plain_text = ""

for letter in cipher_text:
index = key.index(letter)
plain_text += chars[index]

print(f"encrypted message: {cipher_text}")
print(f"original message : {plain_text}")


Watch video Encryption program in Python 🔐 online, duration hours minute second in high quality that is uploaded to the channel Bro Code 17 November 2022. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 121,549 times and liked it 3.4 thousand visitors.