Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ES6 Awesomeness
const _DICTIONARY = new Array(96).fill('').map((a,v) => String.fromCharCode(32 + v));
const _encode_rot32 = function(string) {
return, val => _DICTIONARY[(32 + _DICTIONARY.indexOf(val)) % _DICTIONARY.length]).join('');
const _decode_rot32 = function(string) {
return, val => _DICTIONARY[(_DICTIONARY.indexOf(val) - 32 + _DICTIONARY.length) % _DICTIONARY.length]).join('');
// Usage
_encode_rot32('hello world');
let secret = _encode_rot32('hello world');
let plain = _decode_rot32(secret);

This comment has been minimized.

Copy link

soundyogi commented Dec 5, 2016


[] would be even shorter!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.