Random Substitution Cipher

This commit is contained in:
2019-11-11 12:40:07 +01:00
parent 4f38f0caa1
commit 67173a0f94

View File

@@ -0,0 +1,7 @@
// https://www.codewars.com/kata/random-substitution-cipher/javascript
function randomSub() {
const alph = 'abcdefghijklmnopqrstuvwxyz'.split``;
const rnd = alph.slice().sort(() => Math.random()-0.5);
return alph.reduce((res, k, i) => (res[k] = rnd[i], res), {});
}