Skip to content

Instantly share code, notes, and snippets.

View sachinsharma's full-sized avatar

Sachin Sharma sachinsharma

View GitHub Profile
var alphabet = 'abcdefghijklmnopqrstuvwxyz',
shipher = [],
key,
output = [];
function generateKey(input, string){
for(var j = 0; j < input.length; j++){
var numRand = Math.floor( Math.random() * (string.length-1) ); //gets a random integer between [0 - alphabet.length]
shipher.push( string.charAt(numRand).toUpperCase() ); //appends next char to shipher.
}