Skip to content

Instantly share code, notes, and snippets.

@hueitan
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hueitan/e0b04af4e4bc1376e099 to your computer and use it in GitHub Desktop.
Save hueitan/e0b04af4e4bc1376e099 to your computer and use it in GitHub Desktop.
function arr_encryption(msg) {
  var message = msg.split(' ').join('.'),
      output = '';
      
  // add . if needed
  for (k=0;k<message.length % 6;k++) {
    message += '.';
  }
  
  // [Attack.at.noon] => change
  for (j=0;j<6;j++) {
  	for (i=j;i<message.length;i+=6) {
      output += message[i];
  	}
    if (j<5)output += ' ';
  }
  return output;
}

105 char

m = arguments[j=0]
  
while(m.length %6) m += O=o=' '

for (;j<6;O += o)
  for (i=j++;d=m[i];i+=6) 
    O += d == o ? '.' : d

return O.trim()

best answer from someone else

m = arguments[0]
i = 6
r = '' 
for (; i; i && (r += ' '))
  for (j = -i--; j < m.length-i; r += t > ' ' ? t : '.')
    t = m[j += 6] || '.'  
return r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment