From 67173a0f9475e4888ab1464bad15820f5452e1bb Mon Sep 17 00:00:00 2001 From: Grzegorz Kucmierz Date: Mon, 11 Nov 2019 12:40:07 +0100 Subject: [PATCH] Random Substitution Cipher --- random-substitution-cipher/index.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 random-substitution-cipher/index.js diff --git a/random-substitution-cipher/index.js b/random-substitution-cipher/index.js new file mode 100644 index 0000000..6850b42 --- /dev/null +++ b/random-substitution-cipher/index.js @@ -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), {}); +} \ No newline at end of file