Skip to content

Instantly share code, notes, and snippets.

@raganwald
Created May 23, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raganwald/5ab12adc34b4d9a30f42 to your computer and use it in GitHub Desktop.
Save raganwald/5ab12adc34b4d9a30f42 to your computer and use it in GitHub Desktop.
Secret Decoder Ring
const SecretDecoderRing = {
encode: function (plaintext) {
return plaintext
.split('')
.map( char => char.charCodeAt() )
.map( code => code + 1 )
.map( code => String.fromCharCode(code) )
.join('');
},
decode: function (cyphertext) {
return cyphertext
.split('')
.map( char => char.charCodeAt() )
.map( code => code - 1 )
.map( code => String.fromCharCode(code) )
.join('');
}
}
@raganwald
Copy link
Author

Want to learn the latest cryptography techniques... in JavaScript?

JavaScript Allongé, the “Six” Edition has you covered!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment