
Scramble string N times in Node.JS
let myStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz\\\"";
function scramble(str, times) {
str = Buffer.from(str, 'utf8');
console.log(str + " >>>----> " + str.length + " chars");
for (let i = 1; i <= times; i++) {
let orig = Math.floor(Math.random() * str.length);
let dest = Math.floor(Math.random() * str.length);
let temp = str[orig];
str[orig] = str[dest]