Skip to content

Instantly share code, notes, and snippets.

@madr
Last active September 4, 2017 15:29
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 madr/1de2dc299c691d9406cf3f4853f4e08f to your computer and use it in GitHub Desktop.
Save madr/1de2dc299c691d9406cf3f4853f4e08f to your computer and use it in GitHub Desktop.
function encrypt (str) {
return str.replace(/([^aeiouöäå01-9])/gi, (c) => { return `${c}o${c}`; });
}
function decrypt (str) {
return str.replace(/([^aeiouöäå01-9])o([^aeiouöäå01-9])/gi, (origin, first, last) => {
return (first == last)? first: origin;
});
}
let encrypted = encrypt("Rövarspråket"); // "RoRövovarorsospoproråkoketot"
let decrypted = decrypt(encrypted); // "Rövarspråket"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment