| | |
key strength
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2009
Posts: 16
Reputation:
Solved Threads: 0
Hi,
I'm trying to create a program which provides a key strength. Visual studio don't show errors, but the program hangs on QuadWordFromBigEndian functions. Whats wrong?
Program stop workin on this line:
An show this error:
"Index was outside the bounds of the array."
But I do not know how to fix. What should be the array index.
Thanks
I'm trying to create a program which provides a key strength. Visual studio don't show errors, but the program hangs on QuadWordFromBigEndian functions. Whats wrong?
Program stop workin on this line:
C# Syntax (Toggle Plain Text)
01.x = ( (((UInt64)block[0]) << 56) | (((UInt64)block[1]) << 48) | 02. (((UInt64)block[2]) << 40) | (((UInt64)block[3]) << 32) | 03. (((UInt64)block[4]) << 24) | (((UInt64)block[5]) << 16) | 04. (((UInt64)block[6]) << 8) | ((UInt64)block[7]) 05. );
An show this error:
"Index was outside the bounds of the array."
But I do not know how to fix. What should be the array index.
Thanks
C# Syntax (Toggle Plain Text)
private void button1_Click(object sender, EventArgs e) { byte[] sec_key = System.Text.Encoding.UTF8.GetBytes(textBox1.Text); if (IsWeakKey(sec_key)) { label1.Text = "Yes"; } else { label1.Text = "No"; } } private static bool IsLegalKeySize(byte[] sec_key) { if (sec_key.Length == 8) return(true); return(false); } private static UInt64 QuadWordFromBigEndian(byte[] block) { UInt64 x; x = ( (((UInt64)block[0]) << 56) | (((UInt64)block[1]) << 48) | (((UInt64)block[2]) << 40) | (((UInt64)block[3]) << 32) | (((UInt64)block[4]) << 24) | (((UInt64)block[5]) << 16) | (((UInt64)block[6]) << 8) | ((UInt64)block[7]) ); return (x); } public static bool IsWeakKey(byte[] sec_key) { UInt64 key = QuadWordFromBigEndian(sec_key); if ((key == 0x0101010101010101) || (key == 0xfefefefefefefefe) || (key == 0x1f1f1f1f0e0e0e0e) || (key == 0xe0e0e0e0f1f1f1f1)) { return (true); } else { return (false); } }
•
•
Join Date: Oct 2009
Posts: 91
Reputation:
Solved Threads: 8
0
#2 15 Days Ago
Have you ensured the length of the data you're feeding to QuadWordFromBigEndian is 8 (or more) bytes?
...Either by forcing the call to IsLegalKeySize() or by running it in Debug mode with an assert...
Then test it with something like this:
...Either by forcing the call to IsLegalKeySize() or by running it in Debug mode with an assert...
C# Syntax (Toggle Plain Text)
private static UInt64 QuadWordFromBigEndian(byte[] block) { System.Diagnostics.Debug.Assert(block.Length.Equals(8)); UInt64 x; x = ( (((UInt64)block[0]) << 56) | (((UInt64)block[1]) << 48) | (((UInt64)block[2]) << 40) | (((UInt64)block[3]) << 32) | (((UInt64)block[4]) << 24) | (((UInt64)block[5]) << 16) | (((UInt64)block[6]) << 8) | ((UInt64)block[7]) ); return (x); }
Then test it with something like this:
C# Syntax (Toggle Plain Text)
static void Main(string[] args) { byte[] block = {2,2,2,2,2,2,2,2}; UInt64 x = QuadWordFromBigEndian(block); System.Diagnostics.Trace.WriteLine(x); }
Last edited by thines01; 15 Days Ago at 9:50 am. Reason: omission
![]() |
Similar Threads
- Wireless connection fails when WEP key set (Networking Hardware Configuration)
- Apostrophe - How to find the key location. (Windows 95 / 98 / Me)
- Keyboard Issue: New IE window opens when using the "L" key. (Viruses, Spyware and other Nasties)
- deleting registry key for error code 19 (Windows NT / 2000 / XP)
- Don't Ignore the Windows Logo Key (Windows tips 'n' tweaks)
Other Threads in the C# Forum
- Previous Thread: Is Visual Studio Team Suite the preferred developer tool?
- Next Thread: Syntax error in INSERT INTO statement
| Thread Tools | Search this Thread |
.net access algorithm angle array asp.net barchart bitmap box broadcast c# capturing check checkbox client combobox control conversion csharp custom database datagrid datagridview dataset datetime dbconnection degrees delegate design development disappear draganddrop drawing encryption enum eventhandlers excel file firefox form format forms function gdi+ image index input install java label leak libraries list listbox loop mandelbrot math monodevelop mouseclick msword mysql operator path pause photoshop picturebox pixelinversion post programming radians regex remoting resourcefile richtextbox round server sleep socket sql statistics stream string table tcpclientchannel text textbox thread time timer update usercontrol validation virtualization visualbasic visualstudio webbrowser windows winforms wpf xml





