Click here to Skip to main content
15,913,090 members
Home / Discussions / C#
   

C#

 
GeneralEvents and Model Logic Pin
Leslie Sanford21-Jul-04 16:44
Leslie Sanford21-Jul-04 16:44 
GeneralRe: Events and Model Logic Pin
Heath Stewart22-Jul-04 3:43
protectorHeath Stewart22-Jul-04 3:43 
Generalpassing a form control to a class Pin
budha_man_9921-Jul-04 11:51
budha_man_9921-Jul-04 11:51 
GeneralRe: passing a form control to a class Pin
Colin Angus Mackay21-Jul-04 14:06
Colin Angus Mackay21-Jul-04 14:06 
GeneralRe: passing a form control to a class Pin
budha_man_9922-Jul-04 4:50
budha_man_9922-Jul-04 4:50 
GeneralRe: passing a form control to a class Pin
Colin Angus Mackay22-Jul-04 5:21
Colin Angus Mackay22-Jul-04 5:21 
GeneralRe: passing a form control to a class Pin
budha_man_9922-Jul-04 5:28
budha_man_9922-Jul-04 5:28 
Generalresize tabPages problem Pin
Andy H21-Jul-04 11:32
Andy H21-Jul-04 11:32 
Generalcolor button example Pin
ddelapasse21-Jul-04 9:20
ddelapasse21-Jul-04 9:20 
GeneralRe: color button example Pin
Gary Thom21-Jul-04 9:58
Gary Thom21-Jul-04 9:58 
GeneralRe: color button example Pin
Anonymous21-Jul-04 10:29
Anonymous21-Jul-04 10:29 
GeneralRe: color button example Pin
Gary Thom22-Jul-04 9:41
Gary Thom22-Jul-04 9:41 
Generalcut/copy/paste/undo Pin
HappyPaws21-Jul-04 8:36
HappyPaws21-Jul-04 8:36 
GeneralRe: cut/copy/paste/undo Pin
Heath Stewart21-Jul-04 9:18
protectorHeath Stewart21-Jul-04 9:18 
GeneralRe: cut/copy/paste/undo Pin
Gary Thom21-Jul-04 10:04
Gary Thom21-Jul-04 10:04 
GeneralRe: cut/copy/paste/undo Pin
Jay Shankar21-Jul-04 22:36
Jay Shankar21-Jul-04 22:36 
QuestionCan you pass parameters to properties? Pin
inyoursadachine21-Jul-04 7:11
inyoursadachine21-Jul-04 7:11 
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 />
}

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.