Return to Snippet

Revision: 69101
at April 20, 2015 22:43 by Balamir


Initial Code
function generateHexString(length) {
  var ret = "";
  while (ret.length < length) {
    ret += Math.random().toString(16).substring(2);
  }
  return ret.substring(0,length);
}

// 40-/64-bit WEP: 10 digit key
alert("40-bit:" + generateHexString(10));

// 104-/128-bit WEP: 26 digit key
alert("104-bit:" + generateHexString(26))

// 256-bit WEP: 58 digit key
alert("256-bit:" + generateHexString(58));

Initial URL
http://stackoverflow.com/questions/5398737/how-can-i-make-a-simple-wep-key-generator-in-javascript

Initial Description
If you wanted to generate something based on a fixed string input, there are methods for doing that as well... this should give you what you are looking for in terms of just a straight random hex string of the correct length.

Initial Title
Hex String Generator

Initial Tags

                                

Initial Language
JavaScript