Click here to Skip to main content
15,891,938 members
Home / Discussions / C#
   

C#

 
AnswerRe: Can you pass parameters to properties? Pin
Gary Thom21-Jul-04 8:27
Gary Thom21-Jul-04 8:27 
Generalweb services quest Pin
pelos21-Jul-04 6:42
pelos21-Jul-04 6:42 
GeneralRe: web services quest Pin
VenkatFor.NET21-Jul-04 7:08
VenkatFor.NET21-Jul-04 7:08 
GeneralRe: web services quest Pin
pelos21-Jul-04 12:49
pelos21-Jul-04 12:49 
GeneralReportingServicesWebServer Problem Pin
clydeJones21-Jul-04 6:26
clydeJones21-Jul-04 6:26 
GeneralC# equivalent for charCodeAt Pin
Mark Peters 2157521-Jul-04 4:56
Mark Peters 2157521-Jul-04 4:56 
GeneralRe: C# equivalent for charCodeAt Pin
Nick Parker21-Jul-04 5:49
protectorNick Parker21-Jul-04 5:49 
GeneralcharCodeAt equivalent in C# Pin
Mark Peters 2157521-Jul-04 4:46
Mark Peters 2157521-Jul-04 4:46 
Hi there,

I was wondering if someone knows the C# equivalent for charCodeAt. This is een JScript method
that converts an string to Unicode and encodes this at base 16 (toString(16))
This project generates strong (WEP) key's for protecting WIFI access points.
Anyone got a clue??

Help would be appreciated!

Mark van den Broek
mvdbroek@kg.nl

This is the original JScript source
// generate a WEP key with the specified key length in bytes
//(5/13/16/29 bytes for 64/128/152/256-bit WEP
function gen_key(keyLengthInBytes) {<br />
	for (i = 0; i < keyLengthInBytes; i++)<br />
	{<br />
                // creates the ASCII version of the WEP key<br />
		ascWEPkey += charArray[gen_prn()];  <br />
	}<br />
<br />
	for (i = 0; i < ascWEPkey.length; i++)<br />
	{<br />
                // creates the HEX WEP key from the ASCII <br />
    	        hexWEPkey += ascWEPkey.charCodeAt(i).toString(16);<br />
	}<br />
}


This is what i got so far
private string ASCII_KEY, HEX_KEY;<br />
private char[] charArray = new char [95] { <br />
' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')','*', '+', ',', '-', '.', '/', <br />
'0', '1', '2', '3', '4', '5', '6', '7','8', '9', ':', ';', '<', '=', '>', '?', <br />
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', <br />
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', <br />
'\'', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', <br />
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'};<br />
<br />
private void GenerateWEPKey(int KeyLength) { //64 or 128<br />
    for (int i = 0; i < KeyLength; i++) {<br />
	ASCII_KEY += charArray[GenPseudoNo()];  // creates the ASCII version of the WEP key<br />
    }<br />
    for (int i = 0; i < ASCII_KEY.Length; i++) {<br />
	HEX_KEY += charCodeAt(ASCII_KEY,i);   // creates the HEX WEP key from the ASCII <br />
    }<br />
    //For testing purposes<br />
    MessageBox.Show(HEX_KEY);<br />
}<br />
<br />
private int GenPseudoNo() {<br />
    Random rdm = new Random();// generates a pseudo-random number<br />
    return (int)Math.Floor(rdm.NextDouble() * charArray.Length);// range is 0 ~ 94<br />
}<br />
<br />
private string charCodeAt(string ASCII, int index) {<br />
    System.Text.ASCIIEncoding AE = new System.Text.ASCIIEncoding ( );<br />
    byte [ ] alphabetArray = AE.GetBytes ( ASCII );<br />
    System.Text.StringBuilder sb = new System.Text.StringBuilder();<br />
<br />
    for ( int x = 0; x <= alphabetArray.Length - 1; x++ ) {<br />
        sb.Append ( string.Format ( "{0}", alphabetArray [ x ]));<br />
    }<br />
    return sb.ToString(index,2);<br />
}

QuestionHow to get the Internet IP Pin
sixefftee21-Jul-04 3:49
sixefftee21-Jul-04 3:49 
AnswerRe: How to get the Internet IP Pin
Nick Parker21-Jul-04 5:58
protectorNick Parker21-Jul-04 5:58 
AnswerRe: How to get the Internet IP Pin
Heath Stewart21-Jul-04 6:43
protectorHeath Stewart21-Jul-04 6:43 
GeneralRe: How to get the Internet IP Pin
Anonymous21-Jul-04 17:48
Anonymous21-Jul-04 17:48 
GeneralRe: How to get the Internet IP Pin
Broken God21-Jul-04 19:07
Broken God21-Jul-04 19:07 
GeneralRe: How to get the Internet IP Pin
Heath Stewart22-Jul-04 3:30
protectorHeath Stewart22-Jul-04 3:30 
AnswerRe: How to get the Internet IP Pin
TalkingBabb0t21-Jul-04 17:19
TalkingBabb0t21-Jul-04 17:19 
GeneralUser interface samples Pin
machocr21-Jul-04 2:51
machocr21-Jul-04 2:51 
GeneralRe: User interface samples Pin
Nick Parker21-Jul-04 3:04
protectorNick Parker21-Jul-04 3:04 
Generalnotify in taskmanager Pin
Ravikumar_mv21-Jul-04 1:53
Ravikumar_mv21-Jul-04 1:53 
GeneralRe: notify in taskmanager Pin
Ravikumar_mv21-Jul-04 1:59
Ravikumar_mv21-Jul-04 1:59 
GeneralRe: notify in taskmanager Pin
Heath Stewart21-Jul-04 6:40
protectorHeath Stewart21-Jul-04 6:40 
GeneralRe: notify in taskmanager Pin
Ravikumar_mv21-Jul-04 18:48
Ravikumar_mv21-Jul-04 18:48 
GeneralClosing Tcp connections // (for Axel Charpentier) Pin
Ahmad Mehrbod21-Jul-04 1:50
Ahmad Mehrbod21-Jul-04 1:50 
GeneralRe: Closing Tcp connections // (for Axel Charpentier) Pin
Heath Stewart21-Jul-04 6:34
protectorHeath Stewart21-Jul-04 6:34 
GeneralProblems with program start and install Pin
arjasepp21-Jul-04 0:51
arjasepp21-Jul-04 0:51 
Generalconvert XML X.509Certificates Pin
pelos21-Jul-04 0:47
pelos21-Jul-04 0:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.