|
| 1 | +# 🔒 CAESAR CIPHER 🔒 |
| 2 | +The Caesar cipher is a substitution cipher where each letter in the plaintext is shifted by a fixed number of places down the alphabet. |
| 3 | + |
| 4 | +## How It Works |
| 5 | +- Choose a shift value (e.g., 3). |
| 6 | +- Replace each letter with the letter that is `shift` positions down the alphabet. |
| 7 | +- Wrap around to the beginning of the alphabet if necessary. |
| 8 | +- USE YOUR CIPHER WHEEL! |
| 9 | + |
| 10 | +## Decrypting Caesar Ciphers |
| 11 | +> [!SUCCESS] Task |
| 12 | +> Decrypt the following ciphers. Note that **punctuation matters** when inputting your answers. Upper and lower case does not matter. |
| 13 | +> |
| 14 | +> The following all use a Caesar cipher with different shift values. |
| 15 | +
|
| 16 | +### Cipher 1 |
| 17 | +Y qcapcr kcqqyec uyq upgrrcl ml rfc uyjjq md rfc aytcpl, uygrgle dmp qmkcmlc ajctcp clmsef rm qmjtc gr. |
| 18 | + |
| 19 | +<!-- Shift: 3 --> |
| 20 | +<div class="answer-box"> |
| 21 | + <input class="answer-input" type="text" id="answerinput1" placeholder="Enter your answer"> |
| 22 | + <button class="answer-button" onclick="checkAnswer('answerinput1', 'result1', 'QSBzZWNyZXQgbWVzc2FnZSB3YXMgd3JpdHRlbiBvbiB0aGUgd2FsbHMgb2YgdGhlIGNhdmVybiwgd2FpdGluZyBmb3Igc29tZW9uZSBjbGV2ZXIgZW5vdWdoIHRvIHNvbHZlIGl0Lg==')">Check Answer</button> |
| 23 | +</div> |
| 24 | + |
| 25 | +<div id="result1"></div> |
| 26 | + |
| 27 | +### Cipher 2 |
| 28 | +Oek adem jxqj vuubydw oek wuj mxud oekhu ijqdtydw yd q xywx fbqsu... ikttud khwu je zkcf?... Y tedj xqlu yj. - Sqfjqyd Zqsa Ifqhhem. |
| 29 | + |
| 30 | +<!-- Shift: 3 --> |
| 31 | +<div class="answer-box"> |
| 32 | + <input class="answer-input" type="text" id="answerinput2" placeholder="Enter your answer"> |
| 33 | + <button class="answer-button" onclick="checkAnswer('answerinput2', 'result2', 'WW91IGtub3cgdGhhdCBmZWVsaW5nIHlvdSBnZXQgd2hlbiB5b3VyZSBzdGFuZGluZyBpbiBhIGhpZ2ggcGxhY2UuLi4gc3VkZGVuIHVyZ2UgdG8ganVtcD8uLi4gSSBkb250IGhhdmUgaXQuIC0gQ2FwdGFpbiBKYWNrIFNwYXJyb3cu')">Check Answer</button> |
| 34 | +</div> |
| 35 | + |
| 36 | +<div id="result2"></div> |
| 37 | + |
| 38 | +### Cipher 3 |
| 39 | +Liztqvo, pwtl ug pivl. Vwbpqvo jmiba i Rmb bew pwtqlig, ivl zqopb vwe gwc kiv aidm nqnbg xwcvla xmz xmzawv. Bpiba bew pcvlzml xwcvla wnn nwz i niuqtg wn nwcz. |
| 40 | + |
| 41 | +<!-- Shift: 3 --> |
| 42 | +<div class="answer-box"> |
| 43 | + <input class="answer-input" type="text" id="answerinput3" placeholder="Enter your answer"> |
| 44 | + <button class="answer-button" onclick="checkAnswer('answerinput3', 'result3', 'RGFybGluZywgaG9sZCBteSBoYW5kLiBOb3RoaW5nIGJlYXRzIGEgSmV0IHR3byBob2xpZGF5LCBhbmQgcmlnaHQgbm93IHlvdSBjYW4gc2F2ZSBmaWZ0eSBwb3VuZHMgcGVyIHBlcnNvbi4gVGhhdHMgdHdvIGh1bmRyZWQgcG91bmRzIG9mZiBmb3IgYSBmYW1pbHkgb2YgZm91ci4=')">Check Answer</button> |
| 45 | +</div> |
| 46 | + |
| 47 | +<div id="result3"></div> |
| 48 | + |
| 49 | +<script> |
| 50 | + function checkAnswer(inputId, resultId, enAnswer) { |
| 51 | + const input = document.getElementById(inputId); |
| 52 | + const result = document.getElementById(resultId); |
| 53 | + let correctAnswer; |
| 54 | + |
| 55 | + try { |
| 56 | + correctAnswer = atob(enAnswer); |
| 57 | + } catch (e) { |
| 58 | + result.className = 'error'; |
| 59 | + result.textContent = e; |
| 60 | + result.style.display = 'block'; |
| 61 | + return; |
| 62 | + } |
| 63 | + |
| 64 | + if (input.value.trim().toLowerCase() === correctAnswer.toLowerCase()) { |
| 65 | + result.className = 'correct'; |
| 66 | + result.textContent = '✓ Correct Answer!'; |
| 67 | + } else { |
| 68 | + result.className = 'incorrect'; |
| 69 | + // result.textContent = '✗ Incorrect. Try again!'; |
| 70 | + result.textContent = correctAnswer; |
| 71 | + } |
| 72 | + |
| 73 | + result.style.display = 'block'; |
| 74 | + } |
| 75 | +</script> |
0 commit comments