Converting a string to a 64 bit WEP KEY  
Author Message
ckob





PostPosted: Visual C# General, Converting a string to a 64 bit WEP KEY Top

2 Questions:
I have been trying to find a tutorial on this and even asked in other forums so far no luck. What I want to do is convert a string to a 64 bit hexadecimal WEP KEY For example:

Text : "santa"

64 bit hex : "DA3011B523"

I also have a form the user will enter data into I want to then have the form to to a website automatically tell it what part of the site to go to and then fill in the info and press the save button on the website, is this possible and if it is how do I do it.


I'm pretty new to C# but would really like to get this going.


Visual C#17  
 
 
boban.s





PostPosted: Visual C# General, Converting a string to a 64 bit WEP KEY Top

Try here:
http://www.codeproject.com/csharp/wepkey_generator.asp

 
 
ckob





PostPosted: Visual C# General, Converting a string to a 64 bit WEP KEY Top

I tried that already but it doesn't convert correctly it gives me 73616E7461 for "santa" which isn't correct.

Thanks though


 
 
James Curran





PostPosted: Visual C# General, Converting a string to a 64 bit WEP KEY Top

There is no "official" method of converting a string into a WEP key. Each wifi vendor has created their own algorithm to do it. The hex number is the only important/useful one. The string to hex feature is just a convenience they throw in.

So, based on that, there's really no way of determining the algorithm based on one sample of the conversion. With several sets of input/output it may be possible, but it would mostly be just trial & error.



 
 
ckob





PostPosted: Visual C# General, Converting a string to a 64 bit WEP KEY Top

well I have used this for awhile and it has worked with every router I've used.

http://www.powerdog.com/wepkey.cgi



 
 
ckob





PostPosted: Visual C# General, Converting a string to a 64 bit WEP KEY Top

hoping someone else might have an answer.

 
 
James Curran





PostPosted: Visual C# General, Converting a string to a 64 bit WEP KEY Top

You got me interested, so I tracked down the algorithm, and converted it to C#:



public void Main(string[] args)
{
string str = "santa";

byte[] result = ComputeWep128(str);

Console.WriteLine(BitConverter.ToString(result));

List<
byte[]> result2 = ComputeWep40(str);
Console.WriteLine(BitConverter.ToString(result2[
0]));

}

byte[] ComputeWep128(string str)
{
byte[] result = ComputeWep156(str);
Array.Resize(
ref result, 13);
return result;
}

byte[] ComputeWep156(string str)
{
while (str.Length < 64)
str = str + str;

str = str.Substring(
0,64);

byte[] data = System.Text.Encoding.ASCII.GetBytes(str);
MD5 md5 =
new System.Security.Cryptography.MD5CryptoServiceProvider();
return md5.ComputeHash(data);
}

List<
byte[]> ComputeWep40(string str)
{
byte[] pseed = new byte[4];
int i = 0;
byte[] data = System.Text.Encoding.ASCII.GetBytes(str);
foreach(byte b in data)
{
pseed[ i ] ^= b;
i = (++i) &
3;
}
int seed = BitConverter.ToInt32(pseed, 0);
List<
byte[]> result = new List<byte[]>();
for (i = 0; i < 4; ++i)
{
byte[] wep = new byte[5];
for(int j = 0; j < 5; ++j)
{
seed = (
214013 * seed + 0x269ec3) & 0xFFFFFF;
byte keybyte =(byte) (seed >> 16);
wep[j] = keybyte;
}
result.Add(wep);
}
return result;
}



 
 
ckob





PostPosted: Visual C# General, Converting a string to a 64 bit WEP KEY Top

Thanks im giving it a shot I really appreciate all the help im getting on these forums.