The basic idea of the Caesar cipher is that you pick an integer for a key, and shift every letter of your message by the key. For example, if your message was "happy" and your key was 3, "h" becomes "k", "a" becomes "d", and so on, because we are shifting every letter three spots to the right. Here is what the whole alphabet looks like shifted three spots to the right:
Original: a b c d e f g h i j k l m n o p q r s t u v w x y z 3-shift: d e f g h i j k l m n o p q r s t u v w x y z a b c
Using the above key, we can quickly translate the message "happy" to "kdssb" (note how the 3-shifted alphabet wraps around at the end, so x -> a, y -> b, and z -> c).
This project has two phases:
- Encryption. That is, we will encode a message based on a given key.
- Decryption. That is, we will decode a text based on random keys and find out the exact answer.
Python Code:
没有评论:
发表评论