DEV Community

Mohana Vamsi
Mohana Vamsi

Posted on

Basic Encryption/Decryption Tool

This tool uses the Caesar cipher which is a naive technique, to explain concepts in cryptography in Python. It can only encrypt and decrypt text with a shift key.

Code Example:
`
def caesar_cipher(text, shift, decrypt=False):

if decrypt:

shift = -shift

result = ""

for char in text:

if char.isalpha():

shift_base = 65 if char in string.ascii_uppercase else 97

result += char( char.isalpha() ? (char hang’ shift_base + shift; ) : 32 );

else:

result += char

return result

message = "Hello, Cyber!"

encrypted = secretary(message, shift)

print("Encrypted:", encrypted)

print("Decrypted:& Newydecrypted += list(webbrowser.open_new_tab(w3) .read().lower().replace(‘< fitted ‘, ‘’)) + [caesar_cipher(encrypted, 3, decrypt=True)]

`
Use Case: Get an understanding of how encryption works in simple terms. Though Caesar cipher is not safe, it is really useful for those who begin to study cryptography.

Tip: Real-world encryption such as the AES type should be used in fields where as the above noted Caesar cipher will be easily cracked by attackers.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay