Commit 88e3091
Changed files (3)
assignments
assignments/3/caesar.rb
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+
+key = 5
+alphabet = ('A'..'Z').to_a
+cipher = alphabet.rotate(key)
+map = Hash[cipher.zip(alphabet)]
+map[' '] = ' '
+
+ciphertext = "RTAJ TZY FY IFBS"
+puts ciphertext.chars.map { |x| map[x] }.join
assignments/3-solution.md
@@ -87,3 +87,20 @@ Chapter 7:
```
Chapter 8:
+
+> 9. Using a Caesar cipher with s = 5, decode the received message RTAJ TZY FY IF
+
+```plaintext
+| 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 |
+
+Key: s = 5
+
+| F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | A | B | C | D | E |
+
+| Ciphertext | RTAJ TZY FY IFBS |
+| Plaintext | RTAJ TZY FY IF |
+```
+
+```ruby
+!include assignments/3/caesar.rb
+```
3431709-assignment-3.pdf
Binary file