Caesar Cipher Encryption:Cryptography(Python)


def encryption(plaintext,key):
    plaintext=plaintext.upper()
    ciphertext = ''
    for i in plaintext:
        n = ord(i)
        value = ((n-65)+ key)%26
        ciphertext = ciphertext + chr(value+65)
    return (ciphertext)

a = encryption("hello",3)
print("after encryption:",a)



OUTPUT
C:\Users\Suraj\venv\hello\Scripts\python.exe C:/Users/Suraj/PycharmProjects/hello/world.py
after encryption: KHOOR

Process finished with exit code 0

No comments

Powered by Blogger.