You are viewing a single comment's thread. Return to all comments →
Javascript
function encryption(s) { const rows = Math.floor(Math.sqrt(s.length)); const columns = Math.ceil(Math.sqrt(s.length)); const realNumberOfRows = s.length > rows * columns? rows + 1:rows; const wordsArray = []; const encryptedArray = []; for(let i = 0; i < realNumberOfRows; i++){wordsArray.push(s.split("").splice(i*columns,columns)); } for(let i = 0; i < columns; i++){ const newWord = []; wordsArray.forEach(item=>newWord.push(item[i])); encryptedArray.push(newWord.join('')); } return encryptedArray.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