├── .eslintrc.yml ├── .github └── workflows │ ├── CI.yml │ └── stale.yml ├── .gitignore ├── .gitpod.yml ├── .htmllintrc ├── .stylelintrc.json ├── .theia └── settings.json ├── LICENSE ├── README.md ├── __tests__ └── helpers-test.js ├── assets ├── 247372c3c0373c4dc76f6a6e99b2697c.jpg ├── 27830b990fa5feced405e3f3d55c4c6b.jpg ├── 5747307011a29592cb7dedcf279a6e81.jpg ├── Caesar_cipher_left_shift_of_3.svg ├── ROT13_table_with_example.svg └── UwGR3qd_d.jpeg ├── babel.config.js ├── helpers.js ├── index.html ├── package.json ├── setup-jest.js └── style.css /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | browser: true 3 | es2021: true 4 | jquery: true 5 | jest: true 6 | extends: 7 | - standard 8 | parserOptions: 9 | ecmaVersion: 12 10 | sourceType: module 11 | rules: 12 | quotes: ["error", "single"] 13 | semi: ["error", "always"] 14 | -------------------------------------------------------------------------------- /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | lint: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | 16 | - name: Install linter 17 | run: npm install 18 | 19 | - name: Check for updates 20 | run: npx ncu 21 | 22 | - name: Lint webpage 23 | run: | 24 | npx htmlhint *.html 25 | npx htmllint *.html 26 | npx markdownlint *.md 27 | npx stylelint *.css 28 | 29 | - name: Lint JavaScript 30 | run: | 31 | npx eslint *.js 32 | 33 | build: 34 | runs-on: ubuntu-latest 35 | 36 | steps: 37 | - uses: actions/checkout@v2 38 | 39 | - name: Npm install 40 | run: | 41 | npm install 42 | 43 | - name: Build webpage 44 | run: | 45 | npm run build --if-present 46 | 47 | - name: Test JavaScript 48 | run: | 49 | npm test 50 | 51 | - name: Archive production artifacts 52 | uses: actions/upload-artifact@v2 53 | with: 54 | name: webpage-${{ github.sha }} 55 | path: | 56 | *.html 57 | *.css 58 | *.js 59 | assets 60 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Mark stale issues and pull requests 2 | 3 | on: 4 | schedule: 5 | - cron: "30 1 * * *" 6 | 7 | jobs: 8 | stale: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/stale@v1 14 | with: 15 | repo-token: ${{ secrets.GITHUB_TOKEN }} 16 | stale-issue-message: 'Stale issue message' 17 | stale-pr-message: 'Stale pull request message' 18 | stale-issue-label: 'no-issue-activity' 19 | stale-pr-label: 'no-pr-activity' 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | tasks: 2 | - init: npm install 3 | command: npm start 4 | - command: echo 5 | -------------------------------------------------------------------------------- /.htmllintrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [], // npm modules to load 3 | 4 | "maxerr": false, 5 | "raw-ignore-regex": false, 6 | "attr-bans": [ 7 | "align", 8 | "background", 9 | "bgcolor", 10 | "border", 11 | "frameborder", 12 | "longdesc", 13 | "marginwidth", 14 | "marginheight", 15 | "scrolling", 16 | "width" 17 | ], 18 | "indent-delta": false, 19 | "indent-style": "nonmixed", 20 | "indent-width": 2, 21 | "indent-width-cont": false, 22 | "spec-char-escape": true, 23 | "text-ignore-regex": false, 24 | "tag-bans": [ 25 | "b", 26 | "i" 27 | ], 28 | "tag-close": true, 29 | "tag-name-lowercase": true, 30 | "tag-name-match": true, 31 | "tag-self-close": false, 32 | "doctype-first": false, 33 | "doctype-html5": false, 34 | "attr-name-style": "dash", 35 | "attr-name-ignore-regex": false, 36 | "attr-no-dup": true, 37 | "attr-no-unsafe-char": true, 38 | "attr-order": false, 39 | "attr-quote-style": "double", 40 | "attr-req-value": true, 41 | "attr-new-line": false, 42 | "attr-validate": true, 43 | "id-no-dup": true, 44 | "id-class-no-ad": true, 45 | "id-class-style": "underscore", 46 | "class-no-dup": true, 47 | "class-style": false, 48 | "id-class-ignore-regex": false, 49 | "img-req-alt": true, 50 | "img-req-src": true, 51 | "html-valid-content-model": true, 52 | "head-valid-content-model": true, 53 | "href-style": false, 54 | "link-req-noopener": true, 55 | "label-req-for": true, 56 | "line-end-style": "lf", 57 | "line-no-trailing-whitespace": true, 58 | "line-max-len": false, 59 | "line-max-len-ignore-regex": false, 60 | "head-req-title": true, 61 | "title-no-dup": true, 62 | "title-max-len": 60, 63 | "html-req-lang": false, 64 | "lang-style": "case", 65 | "fig-req-figcaption": false, 66 | "focusable-tabindex-style": false, 67 | "input-radio-req-name": true, 68 | "input-req-label": false, 69 | "table-req-caption": false, 70 | "table-req-header": false, 71 | "tag-req-attr": false 72 | } 73 | -------------------------------------------------------------------------------- /.stylelintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "stylelint-config-standard" 3 | } 4 | -------------------------------------------------------------------------------- /.theia/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.autoSave": "on", 3 | "editor.cursorSmoothCaretAnimation": true, 4 | "editor.cursorSurroundingLines": 2, 5 | "editor.minimap.enabled": true, 6 | "editor.tabCompletion": "on", 7 | "editor.tabSize": 2, 8 | "editor.useTabStops": false, 9 | "files.eol": "\n", 10 | "git.alwaysSignOff": true, 11 | "git.decorations.colors": true, 12 | "javascript.format.placeOpenBraceOnNewLineForControlBlocks": true, 13 | "javascript.format.placeOpenBraceOnNewLineForFunctions": true, 14 | "typescript.format.placeOpenBraceOnNewLineForControlBlocks": true, 15 | "typescript.format.placeOpenBraceOnNewLineForFunctions": true, 16 | "xml.codeLens.enabled": true, 17 | "xml.format.splitAttributes": true 18 | } 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # crypto-webpage 2 | 3 | [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/video-game-coding-club/crypto-webpage) 4 | [![CI](https://github.com/video-game-coding-club/crypto-webpage/workflows/CI/badge.svg)](https://github.com/video-game-coding-club/crypto-webpage/actions?query=workflow%3ACI) 5 | [![GitHub issues](https://img.shields.io/github/issues-raw/video-game-coding-club/crypto-webpage)](https://github.com/video-game-coding-club/crypto-webpage/issues) 6 | [![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/video-game-coding-club/crypto-webpage)](https://github.com/video-game-coding-club/crypto-webpage/pulls) 7 | 8 | Check your [Hacktoberfest progress](https://hacktoberfest.digitalocean.com/profile)! 9 | 10 | ## Introduction 11 | 12 | We are building a website to learn about building websites and encryption: 13 | 14 | 15 | 16 | This website encrypts messages that you give it using the secret key 17 | that you provide and a Caesar cipher. It will also decrypt messages if 18 | you know the secret key for decryption. For a Caesar cipher, the 19 | secret key to decrypt a message is the opposite of the secret key used 20 | to encrypt the message. For example, if the secret key to encrypt the 21 | message was 4, then the secret key to decrypt the message is -4, or 22 | you can use 26 - 4 = 22. 23 | 24 | Steps: 25 | 26 | 1. When you first arrive at the website's homepage, choose the 27 | language for the homepage prompts. 28 | 29 | 2. Next enter the message that you would like to encrypt or decrypt, 30 | in the first box provided. 31 | 32 | 3. Enter the secret key to encode or decode the message. This must be 33 | an integer. 34 | 35 | 4. Finally, click on the "Encrypt" button and the decoded (or encoded) 36 | message will appear in the last box! 37 | 38 | **10/31/20**: Note that right now the message appears in the result 39 | alert box. 40 | 41 | ### Development Status 42 | 43 | - [x] Field to enter cleartext: 44 | [#1](https://github.com/video-game-coding-club/crypto-webpage/issues/1), 45 | [#13](https://github.com/video-game-coding-club/crypto-webpage/issues/13), 46 | [#53](https://github.com/video-game-coding-club/crypto-webpage/issues/53) 47 | - [x] Field to enter ciphertext: 48 | [#1](https://github.com/video-game-coding-club/crypto-webpage/issues/1), 49 | [#13](https://github.com/video-game-coding-club/crypto-webpage/issues/13), 50 | [#53](https://github.com/video-game-coding-club/crypto-webpage/issues/53) 51 | - [x] Field to enter secret (the shift): 52 | [#1](https://github.com/video-game-coding-club/crypto-webpage/issues/1), 53 | [#14](https://github.com/video-game-coding-club/crypto-webpage/issues/14) 54 | - [x] Function to shift a letter: 55 | [#55](https://github.com/video-game-coding-club/crypto-webpage/issues/55), 56 | [#76](https://github.com/video-game-coding-club/crypto-webpage/issues/76), 57 | [#79](https://github.com/video-game-coding-club/crypto-webpage/issues/79) 58 | - [ ] Function to check that the secret is an integer: 59 | [#54](https://github.com/video-game-coding-club/crypto-webpage/issues/54) 60 | - [x] Function to shift a text: 61 | [#70](https://github.com/video-game-coding-club/crypto-webpage/issues/70) 62 | 63 | ### GitPod Chrome Extension 64 | 65 | You might find the GitPod Chrome extension useful 66 | 67 | 68 | 69 | ## Encryption Methods 70 | 71 | ### Caesar Cipher 72 | 73 | In cryptography, a [Caesar 74 | cipher](https://en.wikipedia.org/wiki/Caesar_cipher), also known as 75 | Caesar's cipher, the shift cipher, Caesar's code or Caesar shift, is 76 | one of the simplest and most widely known encryption techniques. It is 77 | a type of substitution cipher in which each letter in the plaintext is 78 | replaced by a letter some fixed number of positions down the alphabet. 79 | For example, with a left shift of 3, D would be replaced by A, E would 80 | become B, and so on. The method is named after Julius Caesar, who used 81 | it in his private correspondence. 82 | 83 | ![Caesar Cipher](assets/Caesar_cipher_left_shift_of_3.svg) 84 | 85 | ### ROT13 86 | 87 | A special case of the Caesar cipher is known as 88 | [ROT13](https://en.wikipedia.org/wiki/ROT13) ("rotate by 13 places", 89 | sometimes hyphenated ROT-13). ROT13 is a simple letter substitution 90 | cipher that replaces a letter with the 13th letter after it. 91 | 92 | Because there are 26 letters (2×13) in the basic Latin alphabet, ROT13 93 | is its own inverse; that is, to undo ROT13, the same algorithm is 94 | applied, so the same action can be used for encoding and decoding 95 | 96 | ![Example for ROT13](assets/ROT13_table_with_example.svg) 97 | -------------------------------------------------------------------------------- /__tests__/helpers-test.js: -------------------------------------------------------------------------------- 1 | import { shiftLetter, shiftText, isStringInteger } from '../helpers'; 2 | 3 | describe('Fake test', () => { 4 | test('it should pass', () => { 5 | expect(true); 6 | }); 7 | }); 8 | 9 | describe('Shift letters', () => { 10 | test('simple shifts', () => { 11 | expect(shiftLetter('a', 1)).toEqual('b'); 12 | expect(shiftLetter('A', 1)).toEqual('B'); 13 | expect(shiftLetter('a', 3)).toEqual('d'); 14 | expect(shiftLetter('A', 3)).toEqual('D'); 15 | }); 16 | test('wrapping shifts', () => { 17 | expect(shiftLetter('a', 26)).toEqual('a'); 18 | expect(shiftLetter('A', 26)).toEqual('A'); 19 | expect(shiftLetter('a', 77)).toEqual('z'); 20 | expect(shiftLetter('A', 77)).toEqual('Z'); 21 | }); 22 | test('simple negative shifts', () => { 23 | expect(shiftLetter('a', -1)).toEqual('z'); 24 | expect(shiftLetter('A', -1)).toEqual('Z'); 25 | expect(shiftLetter('a', -3)).toEqual('x'); 26 | expect(shiftLetter('A', -3)).toEqual('X'); 27 | }); 28 | test('wrapping negative shifts', () => { 29 | expect(shiftLetter('a', -26)).toEqual('a'); 30 | expect(shiftLetter('A', -26)).toEqual('A'); 31 | expect(shiftLetter('a', -77)).toEqual('b'); 32 | expect(shiftLetter('A', -77)).toEqual('B'); 33 | }); 34 | test('shifting special characters', () => { 35 | expect(shiftLetter('!', 2)).toEqual('!'); 36 | expect(shiftLetter('#', 2)).toEqual('#'); 37 | expect(shiftLetter('.', 2)).toEqual('.'); 38 | expect(shiftLetter(' ', 4)).toEqual(' '); 39 | expect(shiftLetter('ä', 4)).toEqual('ä'); 40 | }); 41 | }); 42 | 43 | describe('Shift text', () => { 44 | test('simple shifts', () => { 45 | expect(shiftText('Apple', 1)).toEqual('Bqqmf'); 46 | }); 47 | }); 48 | 49 | describe('Check integer', () => { 50 | test('integer tests', () => { 51 | expect(isStringInteger('1')).toEqual(true); 52 | expect(isStringInteger('a')).toEqual(false); 53 | expect(isStringInteger('1.2')).toEqual(false); 54 | }); 55 | }); -------------------------------------------------------------------------------- /assets/247372c3c0373c4dc76f6a6e99b2697c.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/video-game-coding-club/crypto-webpage/0476c273afc7f2c02b59ccf39919095666985baf/assets/247372c3c0373c4dc76f6a6e99b2697c.jpg -------------------------------------------------------------------------------- /assets/27830b990fa5feced405e3f3d55c4c6b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/video-game-coding-club/crypto-webpage/0476c273afc7f2c02b59ccf39919095666985baf/assets/27830b990fa5feced405e3f3d55c4c6b.jpg -------------------------------------------------------------------------------- /assets/5747307011a29592cb7dedcf279a6e81.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/video-game-coding-club/crypto-webpage/0476c273afc7f2c02b59ccf39919095666985baf/assets/5747307011a29592cb7dedcf279a6e81.jpg -------------------------------------------------------------------------------- /assets/Caesar_cipher_left_shift_of_3.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 45 | 47 | 48 | 50 | image/svg+xml 51 | 53 | 54 | 55 | 56 | 57 | 62 | 72 |   83 | 88 | 93 | 98 | 103 | 108 | 113 | 118 | 123 | 128 | 137 | 146 | 155 | 164 | 173 | 182 | 191 | 200 | 207 | 216 | 225 | 234 | 243 | 248 | 253 | 260 | 269 | 278 | 283 | 288 | 293 | 298 | 303 | 308 | 313 | 318 | 321 | 330 | 335 | 336 | 341 | 344 | 353 | 358 | 359 | 364 | 369 | 374 | 377 | 386 | 391 | 392 | 397 | 400 | 409 | 414 | 415 | 420 | 425 | 430 | 435 | 440 | 445 | 450 | 455 | 456 | 457 | -------------------------------------------------------------------------------- /assets/ROT13_table_with_example.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 28 | 34 | 35 | 42 | 48 | 49 | 50 | 81 | 93 | 94 | 96 | 97 | 99 | image/svg+xml 100 | 102 | 103 | 104 | 105 | 106 | 111 | 121 | 126 | 131 | 136 | 141 | 146 | 151 | 156 | 161 | 166 | 171 | 176 | 181 | 186 | 191 | 196 | 201 | 206 | 211 | 216 | 221 | 226 | 231 | 236 | 241 | 246 | 251 | 256 | 261 | 266 | 271 | 276 | 281 | 286 | 291 | 296 | 301 | 306 | 311 | 316 | 321 | 326 | 331 | 336 | 341 | 346 | 351 | 356 | 361 | 366 | 371 | 376 | 381 | 384 | 389 | 394 | 399 | 400 | 403 | 408 | 413 | 418 | 419 | 422 | 427 | 432 | 437 | 438 | 441 | 446 | 451 | 456 | 457 | 460 | 465 | 470 | 475 | 476 | 479 | 484 | 489 | 494 | 495 | 498 | 503 | 508 | 513 | 514 | 517 | 522 | 527 | 532 | 533 | 536 | 541 | 546 | 551 | 552 | 555 | 560 | 565 | 570 | 571 | 574 | 579 | 584 | 589 | 590 | 593 | 598 | 603 | 608 | 609 | 612 | 617 | 622 | 627 | 628 | 633 | 638 | 643 | 648 | 653 | 658 | 663 | 668 | 673 | 678 | 681 | 686 | 691 | 696 | 697 | 700 | 705 | 710 | 715 | 716 | 719 | 724 | 729 | 734 | 735 | 738 | 743 | 748 | 753 | 754 | 757 | 762 | 767 | 772 | 773 | 778 | 783 | 788 | 793 | 798 | 803 | 808 | 813 | 818 | 823 | 828 | 833 | 834 | 835 | -------------------------------------------------------------------------------- /assets/UwGR3qd_d.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/video-game-coding-club/crypto-webpage/0476c273afc7f2c02b59ccf39919095666985baf/assets/UwGR3qd_d.jpeg -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [['@babel/preset-env', { targets: { node: 'current' } }]] 3 | }; 4 | -------------------------------------------------------------------------------- /helpers.js: -------------------------------------------------------------------------------- 1 | /* Show the currently selected language and hide all of the other 2 | * languages. 3 | */ 4 | export function selectLanguage (language) { 5 | $('[lang]').each(function () { 6 | if ($(this).attr('lang') === language) { 7 | $(this).show(); 8 | } else { 9 | $(this).hide(); 10 | } 11 | }); 12 | } 13 | /* Due to how scoping works in JavaScript modules, the 14 | * `selectLanguage()` function is only declared in the module but not 15 | * the global scope. The following will declare this function also in 16 | * the `window` (the HTML document) scope so we can call it from the 17 | * HTML document. 18 | */ 19 | window.selectLanguage = selectLanguage; 20 | 21 | function processForm () { // eslint-disable-line no-unused-vars 22 | // Save some values from the form. 23 | var formMessage = $('#inputtext')[0].value; 24 | var formKey = $('#key')[0].value; 25 | 26 | // Check if formKey is actually an integer. 27 | if (!isStringInteger(formKey)) { 28 | alert('The secret key must be an integer. You entered "' + 29 | formKey + '".'); 30 | } else { 31 | // Process the form. 32 | alert('processing form (' + formMessage + ')'); 33 | alert('result: ' + shiftText(formMessage, Number(formKey))); 34 | } 35 | } 36 | window.processForm = processForm; 37 | 38 | /* Check if the string "test" is actually an integer. isNan is false 39 | * if "test" is empty, so check if "test" is empty too. 40 | */ 41 | export function isStringInteger (test) { 42 | if (!(isNaN(test) || test === '')) { 43 | if (Math.round(Number(test)) === Number(test)) { 44 | return true; 45 | } else { 46 | return false; 47 | } 48 | } else { 49 | return false; 50 | } 51 | } 52 | 53 | /* Takes a text and a shift as arguments and returns the shifted 54 | * text. 55 | */ 56 | export function shiftText (text, shift) { 57 | var code = ''; 58 | 59 | for (var i in text) { 60 | code += shiftLetter(text[i], shift); 61 | } 62 | 63 | return code; 64 | } 65 | 66 | /* Takes a letter and a shift as arguments and returns the shifted 67 | * letter. 68 | */ 69 | export function shiftLetter (letter, shift) { 70 | // First change the letter into a number. 71 | var code = letter.charCodeAt(0); 72 | var Acode = 'A'.charCodeAt(0); 73 | var Zcode = 'Z'.charCodeAt(0); 74 | var acode = 'a'.charCodeAt(0); 75 | var zcode = 'z'.charCodeAt(0); 76 | 77 | // Change the shift into a positive number between 0 and 25. 78 | shift = shift % 26; 79 | if (shift < 0) { 80 | shift += 26; 81 | } 82 | 83 | // Only shift if the letter really is a letter. 84 | if (code >= Acode && code <= Zcode) { 85 | // The letter is a capital letter. Shift it. 86 | code += shift; 87 | // If code is too big, wrap it so it isn't. 88 | code = Acode + (code - Acode) % 26; 89 | } else if (code >= acode && code <= zcode) { 90 | // The letter is a lowercase letter. Shift it and wrap it. 91 | code += shift; 92 | code = acode + (code - acode) % 26; 93 | } 94 | 95 | return String.fromCharCode(code); 96 | } 97 | 98 | /* Initialize language setting on page load 99 | * 100 | * The `$(...` is a jQuery shorthand to do something once the page is 101 | * fully loaded and ready. 102 | * 103 | * https://learn.jquery.com/using-jquery-core/document-ready/ 104 | */ 105 | $(function () { 106 | selectLanguage('en'); 107 | }); 108 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Message Translator 6 | 7 | 14 | 15 | 16 | 17 | 18 | 19 | 26 | 27 | 28 | 32 | 33 | 34 | 35 | 36 |
37 |

Cypherbot

38 |

39 | 46 |

47 | 48 | 52 | 59 |

60 | 61 | 68 |

69 | 70 | 77 |

78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 |
86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "license": "Apache-2.0", 3 | "repository": { 4 | "type": "git", 5 | "url": "https://github.com/video-game-coding-club/crypto-webpage.git" 6 | }, 7 | "devDependencies": { 8 | "@babel/core": "^7.12.3", 9 | "@babel/preset-env": "^7.12.1", 10 | "babel-jest": "^26.6.1", 11 | "browser-sync": "^2.26.13", 12 | "eslint": "^7.11.0", 13 | "eslint-config-standard": "^14.1.1", 14 | "eslint-plugin-import": "^2.22.1", 15 | "eslint-plugin-node": "^11.1.0", 16 | "eslint-plugin-promise": "^4.2.1", 17 | "eslint-plugin-standard": "^4.0.1", 18 | "htmllint": "^0.8.0", 19 | "htmllint-cli": "0.0.7", 20 | "http-server": "^0.12.3", 21 | "jest": "^26.6.0", 22 | "jquery": "^3.5.1", 23 | "markdownlint-cli": "^0.24.0", 24 | "npm-check-updates": "^9.1.2", 25 | "stylelint": "^13.7.2", 26 | "stylelint-config-standard": "^20.0.0" 27 | }, 28 | "scripts": { 29 | "start": "browser-sync --no-ui", 30 | "test": "jest" 31 | }, 32 | "jest": { 33 | "setupFiles": [ 34 | "./setup-jest.js" 35 | ] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /setup-jest.js: -------------------------------------------------------------------------------- 1 | import $ from 'jquery'; 2 | global.$ = global.jQuery = $; 3 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-image: url('assets/5747307011a29592cb7dedcf279a6e81.jpg'); 3 | } 4 | 5 | div { 6 | background: #7f7f7f; 7 | background: rgba(255, 255, 255, 0.4); 8 | display: inline-block; 9 | width: fit-content; 10 | } 11 | --------------------------------------------------------------------------------