You are viewing a single comment's thread. Return to all comments →
Javascript
function encryption(s) { const noSpaces = s.replaceAll(' ', ''); const strLen = noSpaces.length; const row = Math.floor(Math.sqrt(strLen)); const col = Math.ceil(Math.sqrt(strLen)); const encryptedArr = []; let pos = 0; for(let i=0; i<strLen; i++) { const str = noSpaces.substr(i, 1); encryptedArr[pos] = encryptedArr[pos] ?? ''; encryptedArr[pos] += str; pos = pos === col-1 ? 0 : pos+1; } return encryptedArr.join(' '); }
Seems like cookies are disabled on this browser, please enable them to open this website
Encryption
You are viewing a single comment's thread. Return to all comments →
Javascript