Here is a simple implementation of an encryption tool in Python using the Caesar cipher method:
Explanation:
- The Caesar cipher is a simple substitution cipher that replaces each letter of the plaintext with a letter a certain number of positions down the alphabet (the shift).
- The
encryptfunction takes a plaintext message and a shift value as input and returns the corresponding ciphertext. It uses theordfunction to get the ASCII code of the characters and thechrfunction to convert the ASCII code back to characters. - The
decryptfunction takes a ciphertext message and a shift value as input and returns the corresponding plaintext. It is the reverse process of the encryption function. - The code sets the message and shift values and then calls the encryption and decryption functions to show how the same message can be encrypted and then decrypted.
No comments:
Post a Comment