how can i make a simple wep key generator in javascript?

故事扮演 提交于 2020-01-02 19:21:14

问题


im trying to make a wep key generator and ive read how wep keys work but i really dont even know how to start making it. can anyone give me an example or direct me to a tutorial? i tried using google but no luck.


回答1:


in javascript...

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));

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.

I'm not sure if there is a standard passphrase to WEP generator, but most limit the input to printable characters, and the algorythms are generally weak.. best bet is to simply use WPA2PSK if you can.



来源:https://stackoverflow.com/questions/5398737/how-can-i-make-a-simple-wep-key-generator-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!