GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — JavaScript-1/Ciphers/Atbash.js at master · prigozh/JavaScript-1 Expand file tree/ Copy pathAtbash.jsMore file actions 24 lines (20 loc) · 842 Bytes / Copy pathAtbash.jsFile metadata and controls24 lines (20 loc) · 842 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 /** * @function Atbash - Decrypt a Atbash cipher * @description - The Atbash cipher is a particular type of monoalphabetic cipher formed by taking the alphabet and mapping it to its reverse, so that the first letter becomes the last letter, the second letter becomes the second to last letter, and so on. * @param {string} str - string to be decrypted/encrypt * @return {string} decrypted/encrypted string * @see - [wiki](https://en.wikipedia.org/wiki/Atbash) */ const Atbash = (str) => { if (typeof str !== 'string') { throw new TypeError('Argument should be string') } return str.replace(/[a-z]/gi, (char) => { const charCode = char.charCodeAt() if (/[A-Z]/.test(char)) { return String.fromCharCode(90 + 65 - charCode) } return String.fromCharCode(122 + 97 - charCode) }) } export default Atbash |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |