|
I have been writing a simple client/server application which functions just fine without encryption. However, I need to add encryption to be compliannt with regulations.
I am using RijndaelManaged objects for encryption. Both sender and reciever have the same hard-coded legal Keys and IV's.
Once I have a TCP socket established, I set my Network Stream using tcpClient.GetStream().
I use one of the stream reader/writer classes (all of them fail so far). For example, I will send a sting using a BinaryWriter bWrite. Then I will look to receive some string using BinaryReader bRead.
On the Send Side:
RijndaelManaged crypt = new RijndaelManaged();
//Insert code to set Key and IV
NetworkStream netStream = tcpClient.GetStream();
CryptoStream coutStream = new CryptoStream(netStream,crypt.CreateEncryptor(Key,IV),CryptoStreamMode.Write);
BinaryWriter bWrite = new BinaryWriter(coutStream);
bWrite("Some Cool String");
bWrite.Flush();
coutStream.FlushFinalBlock();
CryptoStream cinStream = new CryptoStream(netStream,crypt.CreateDecryptor(Key,IV),CryptoStreamMode.Read);
BinaryReader bRead = new BinaryReader(cinStream);
String receivedString = bRead.ReadString();
tcpClient.Close();
On the Recieve Side:
RijndaelManaged crypt = new RijndaelManaged();
//Insert code to set Key and IV
NetworkStream netStream = tcpClient.GetStream();
CryptoStream cinStream = new CryptoStream(netStream,crypt.CreateDecryptor(Key,IV),CryptoStreamMode.Read);
BinaryReader bRead = new BinaryReader(cinStream);
String receivedString = bRead.ReadString();
CryptoStream coutStream = new CryptoStream(netStream,crypt.CreateEncryptor(Key,IV),CryptoStreamMode.Write);
BinaryWriter bWrite = new BinaryWriter(coutStream);
bWrite("Some Cool String");
bWrite.Flush();
coutStream.FlushFinalBlock();
tcpClient.Close();
PROBLEM:
If I simply send from one program and recieve on the other -- everything works fine. It is when I actually send/receive from both that the program hangs.
Any thoughts?
-- modified at 12:09 Wednesday 12th October, 2005
|
|
|
|
|
Are you sure you're not encountering some sort of race condition where the TCP/IP stack is being blocked by a send/receive? If it works fine when one sends and then the other receives, could it be that something like this happens:
ClientA Sends
ClientB Sends
ClientA is blocked because it's waiting for ClientB to receive, so it doesn't pick up any incoming calls
ClientB is blocked because it's waiting for ClientA to receive, so it doesn't pick up any incoming calls
Does that sound logical?
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..."
-Jörgen Sigvardsson
|
|
|
|
|
It sounds logical -- but when I take out the encryption, everything works fine.
For ex, if I remove all references to encryption and attach the BinaryReader/Writers to the network stream, the program functions without trouble. It is when I add the CryptoStreams in that I have trouble.
I wonder if it has something to do with the read/write modes.
What I do note is that with encryption, if I send from A and then close the TCP connection, B recieves just fine. However, B fails to receive until the TCP connection closes.
Very wierd.
|
|
|
|
|
Hey everyone, I already know how to run a macro on an office document with automation, but I was wondering how I can use an external file to specify the macro?
Basically I want to write a Console application that will accept a macro file (BAS file exported from the VBA editor) as a parameter and run it on any specified files. So again....
How do I read a macro from a file then execute it in Word ?
thanks in advance for the help.
|
|
|
|
|
I'm new to c# and i'm creating a console application. I want to add a new List() to my app, but i'm getting a reference error. i've added the line using System.Collections. I've read that List is in System.Collections.Generic but I don't have access to this, only System.Collection.Specialized. Do I have to add a reference in the solution explorer and if so could you point me to which one.
|
|
|
|
|
There is no List class for collections in the .NET BCL 1.0 or 1.1. Is this what you're using (VS.NET 2002 and 2003)?
There is a <a href="http://msdn2.microsoft.com/en-us/library/6sh2ey19(en-US,VS.80).aspx" rel="nofollow">List<T> (List Generic)</a>[<a href="http://msdn2.microsoft.com/en-us/library/6sh2ey19(en-US,VS.80).aspx" target="_blank" rel="nofollow" title="New Window">^</a>] class in the .NET Framework 2.0 (VS.NET 2005 beta) though, under System.Collections.Generic.
You can't use the .NET Framework 2.0 with Visual Studio .NET 2002 or 2003.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello,
Does anybody have any idea about How to work with bar code machine and how to scan and get barcode in C#.Net.
Please provide me some code/Example resource.
Thanks in Advance.
|Muhamad Waqas Butt|
waqasb4all@yahoo.com
www.sktech.freewebspace.com
|
|
|
|
|
This is the 5th or 6th time I've seen this question this month.
Barcode scanners work either with a serial port or, more commonly, are connected to the keyboard port and act just like a second keyboard. Your application can't tell the difference between what is "typed" by the scanner and what is typed by the keyboard.
Normally, the focus is set to a control where the user then scans a barcode. The scanner "types" the information into this control, and so on...
Now, if you want to automatically set the focus so the user doesn't have to, you'll have to handle the keyboard events of the form. You'll have to program the barcode scanner (consult the scanner documentation on how to do this) to prepend and/or append a unique sequence of characters to every barcode it scans. You'll be looking for character combinations prepended and/or appended to the barcode key sequence in the form's keyboard handler events. When you see this combination, you'll have to change the focus to the appropriate control.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Well Thanks for your reply. I will try to search-out some resource for this. And if you know about something about it (for start programming) please inform me.
Thanks and best regards,
|Muhamad Waqas Butt|
waqasb4all@yahoo.com
www.sktech.freewebspace.com
|
|
|
|
|
The best resource you have is the manual on the scanner. When I did this, I spent about 10 minutes reading through the manual. After that, 60 seconds to write the first application and start scanning bar codes.
I learn best by doing...
|
|
|
|
|
Which Barcode Scanner you use and could you sends your piece of code?
Or
Can I download Barcode Scanner Manual from internet?
Thanks in Advance.
|Muhamad Waqas Butt|
waqasb4all@yahoo.com
www.sktech.freewebspace.com
|
|
|
|
|
Can someone shed some light on datagrid formating?
i have 2 requirements
1) Concatenate some fields - ie Address, Town, Zip
2) Set Column field widths
To achieve item 1) ArrayList of Objects is used - where each column is defined by a property.
To acheive item 2) I use a DataTable/DataView and GridColumnStyles
I have been unable to acheive both requirements. With a DataTable I cxannot perform the concatenate (without the use of views). I found some notes on "helper functions" but could only find information for ASP.Net datagrids.
With an ArrayList of Objects, I cannot set the column width because it seems to require a DataTable.
Any help is appreciated...
-- modified at 10:35 Wednesday 12th October, 2005
|
|
|
|
|
hi guyz,
is it possible to write / read image data to /from xml file?
I just've no idea.
Could anyone provide me with code/resource/guidance.
Thankx in advance,
Long Live
|
|
|
|
|
|
Hello,
How can I see the source code for an IRR function in Microsoft.VisualBasic namespace using the Reflector tool, any ideas?
Thank you.
|
|
|
|
|
Hi!
Here's the C# version of the code:
public static double IRR(ref double[] ValueArray, [Optional] double Guess )
{
double num5;
double num6;
int num11;
try
{
num11 = ValueArray.GetUpperBound(0);
}
catch (Exception)
{
throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue1", "ValueArray"));
}
... and so on...
} Start Reflector, open the file Microsoft.VisualBasic.dll (that's the assembly IRR is contained in, just read the documentation on the function to retrieve this information).
Navigate to the class Microsoft.VisualBasic.Financial and there you'll find IRR. Double click the function to see the decompiler window.
Regards,
mav
|
|
|
|
|
I can't navigate within the reflector to the Microsoft.VisualBasic.dll.
All I got is System.System.dll.Microsoft.VisualBasic etc.... How can I open Microsoft.VisualBasic.dll? How can I load assembly into the reflector?
Would you be able to post all of the code. Thank you very much.
-- modified at 9:14 Wednesday 12th October, 2005
I got it thanks again
|
|
|
|
|
My first choice would be to try File/Open, then go find the Microsoft.VisualBasic.dll file. A simple search of the hard drive for the filename reveals that it's in C:\WINDOWS\Microsoft.NET\Framework\version .
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
I found the way of looking up the code using Reflector.
You must go to File -> Cache..
Load the required assembly, and then access the IRR code.
I did add the reference to that assembly, I just really wanted to see how the method was implemented.
Thank you all!
|
|
|
|
|
If a user logs on such as "insert user name here" i want to play a sound "insert sound 1 here", but if a different user logs on, i want to play a different sound.
So can i check what user has loged on? or if a specific user has loged on?
|
|
|
|
|
Have you tried using System.Security.Principal.WindowsIdentity.GetCurrent() to return the WindowsIdentity for the current user? Then, use the Name property to get the user name. Then you can play the appropriate sound for that person.
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..."
-Jörgen Sigvardsson
|
|
|
|
|
Hello All
can any one help me where is the windows atom table and how to navigate it, and how to add and delete values from it
thx
|
|
|
|
|
|