Skip to content

Instantly share code, notes, and snippets.

@dervondenbergen
Created February 25, 2015 23:18
Show Gist options
  • Save dervondenbergen/85e150c5fcba6c8bcc58 to your computer and use it in GitHub Desktop.
Save dervondenbergen/85e150c5fcba6c8bcc58 to your computer and use it in GitHub Desktop.
smaller cipher
i=prompt('Please write the text to cipher:');
s=prompt('Steps to shift:');
t='';
var a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
for (var l = 0; l < i.length; l++) {
n = a.indexOf(i[l].toUpperCase())
f=100
if (n>-1)
f=n+Math.floor(s)
if (f > 25)
f = f-26;
t += a[f] || i[l]
}
alert(t);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment