|
Member 4083157 wrote: I tried to catch CryptographicException, but it causes lot's of problem..
Such as?? Because that's about the only method you have for detecting an invalid key.
|
|
|
|
|
The main problem is that CryptographicException do not throws on some invalid keys. i tried to check them with DES.IsWeakKey and DES.IsSemiWeakKey, but result is always false..
Then, to catch a CryptographicException i need to wait the whole cycle of decryption and it takes some time, and the programm's task is to find the right key in some range of keys. Of course, i use distributed search, but this problem is still actual..
Is there any way to use hash of the encrypted and decrypted data?
|
|
|
|
|
Member 4083157 wrote: Is there any way to use hash of the encrypted and decrypted data?
That would defeat the purpose of encryption pretty quickly now, wouldn't it?? You simply don't have a way around this. There are only three possiblities here.
1. The key is blatantly invalid, such as incorrect length or tampered with.
2. The key is just the wrong key, in which case, the only way to tell is to try and decrypt a message with it.
3. The key is correct.
There's no way to predict in a quick fashion if the key is correct or not. It just has to be tried to find out. That takes time, and there's no way around it.
|
|
|
|
|
|
Why can't you compare it to the key used during encryption?
|
|
|
|
|
Because i don't have such key..
|
|
|
|
|
If you're trying to get hints on how to break the key or encryption, forget it. We're in the business.
|
|
|
|
|
I installed .Net framework 3.0 but not getting the templates of WCF WPF etc. What extra configuration is to be done for that.
Bijay Bhaskar Deo
Thanks & Regard
|
|
|
|
|
Did you install the SDK version of .NET 3.0 or the redistributable version?? Where did you get it from??
|
|
|
|
|
I have a form which has layout like this:
form
|--->usercontrol1
|----->usercontrol2
|---->combobox1
|---->combobox2
What I want to do is when selected item of comboxes changes, unfocus them. I tried this.ActiveControl=null, Findform().usercontrol1.ActiveControl = null, FindForm().usercontrol1.Focus(), FindForm().Focus() etc. on selectedindexchanged event but that comboboxes always stayed focused.
Any other ideas?
|
|
|
|
|
Where do you want to throw the focus after selection has changed?
Also, pay attention to combo box as it has SelectedText (or something like it), so you probably have to deselect that as well. Just a guess.
|
|
|
|
|
I'd like to make usercontrol1 focused.
I'll check SelectedText.
|
|
|
|
|
UserControl's cannot have the focus, however, one of it's child controls can.
|
|
|
|
|
Ok let's forget usercontrol. Do I have to set focus elsewhere to unfocus combobox? If yes how can I focus the form?
|
|
|
|
|
kensai wrote: Do I have to set focus elsewhere to unfocus combobox?
Yes, some control has to have the focus.
kensai wrote: If yes how can I focus the form?
You can't. You have to focus some other control on the form.
|
|
|
|
|
Hello all. I have a couple of questions regarding assemblies.
Can an assembly contain other assemblies?
Can an assembly directly contain types?
Any help would be appreciated. Thanks.
"If you don't know where you're going, you'll probably end up somewhere else." Yogi Berra
|
|
|
|
|
Your question has been already answered in c# forum.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
I created a DLL file in c# 2.0 . After some days i make some change in (opened in 2.0 again) dll and compiled it. may i know it will be creating new version or will be previous version .
Thanks
Sujit
|
|
|
|
|
Check AssemblyInfo and compare them.
|
|
|
|
|
Hiii...
I am receiving this error :--->
Server encountered an internal error. For more information, turn on customErrors in the server's .config file.
Server stack trace:
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
1) After googling, I found that customErrors mode="off can help.
Presently its True on Server side. Like this
RemotingConfiguration.CustomErrorsEnabled(true);
2) I am using .Net 1.1 on the server side and .Net 2.0 on client side.
3) Not getting this problem frequently. It has only 5% chances.
4) When I debugging found some interesting stuff:
class One
{
public string m_sResult = null;
public string GetInfo(string sID)
{
try
{
if(OnRequested != null)
OnRequested(sID);
return m_sResult;
}
catch(Exception ex)
{
WriteLog(“ “);
}
}
}
class Two{
void OnRequestedHandler(string sID)
{
try
{
One.m_sReult = "Done";
}
catch(Exception ex)
{
One.m_sReult = ex.message;
}
}
}
From the client side, I am calling One.GetInfo() method.
a) Event OnRequested(sID) raised and handled by class Two and One.m_sReult is set as "Done".
b) But on client side it returns NULL and also writes Log "Server encountered and internal....." on Server side.
So suggest me, what I should do to solve this problem.
I should use customErrors mode="off for better understanding?
I would appreciate any help or suggestions that anyone can provide.
Thank you.
Sidh
|
|
|
|
|
I doubt the problem is to be found in the code you have provided here. I do not understand why class Two is setting m_sResult when it actually belongs to class One--Bad OO. Can you paste some more code?
|
|
|
|
|
I'm using reflection API's to find the argument types of a methods (such as
in or out etc). For example, consider this method in a class written in C#
public int outerFoo(string strIn, ref double dbRef, out double dbOut) { return 42; }
When using reflection in C++/CLI, I would like to know if an argument is of in or out type. In this case, I should see strIn as in, dbRef as
ref (or in and out type) and dbOut as out type. I got the code written like this
for each ( ParameterInfo^ pi in (((MethodInfo^) methInfo)->GetParameters()))
{
if(pi->IsIn)
..do something
else if(pi->IsOut)
..do something else
}
But IsIn and IsOut always return false. Are these deprecated? Any workarounds?
Any help would be appreciated
Thanks
Fiz
|
|
|
|
|
First of all, this post is also on msdn - but Im not getting any help I hope some of you can help me...
Hi!
I have a small webserver on a pda, which upon request can return some data. The problem is, that after the data to transmit has been buffered, and the socket is called with the shutdown and close command, the socket connection is terminated before all data has been transmitted.
If I add a delay before the shutdown is called on the socket, all data is send correctly. What am I doing wrong?
If I add a delay before the close methode, but after the shutdown methode, the transmission is also stopped before all data has been send.
It seems very wired, since the LingerOption of the socket is enabled...
Really hope someone can tell me what is going on...
Best regards
Martin Jørgensen
Here is the code (I have removed a lot of unnecessay code...):
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Net;
using System.Net.Sockets;
namespace DeviceApplication2
{
class RegulationStatusService
{
private const int PORT = 13000;
private static RegulationStatusService s_Instance = null;
private Thread m_Thread;
private TcpListener m_TCPServer;
private string m_HTTPVersion;
private bool m_IsRunning = false;
public static RegulationStatusService Instance
{
get
{
if (s_Instance == null)
{
s_Instance = new RegulationStatusService();
}
return s_Instance;
}
}
public void Start()
{
if (!m_IsRunning)
{
try
{
IPAddress ipAddr = IPAddress.Any;
m_TCPServer = new TcpListener(ipAddr, PORT);
m_TCPServer.Start();
m_Thread = new Thread(new ThreadStart(Runner));
m_Thread.IsBackground = true;
m_Thread.Start();
m_IsRunning = true;
}
catch { }
}
}
public bool Running
{
get
{
return m_IsRunning;
}
}
private void Runner()
{
while (Running)
{
Socket socket = m_TCPServer.AcceptSocket();
if (!socket.Connected)
continue;
try
{
LingerOption lo = new LingerOption(true, 0);
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, lo);
IList<byte> buffer = new List<byte>(100);
using (NetworkStream stream = new NetworkStream(socket))
{
int b;
while ((b = stream.ReadByte()) != -1 && (b != '\r'))
buffer.Add(Convert.ToByte(b));
}
byte[] ba = new byte[buffer.Count];
buffer.CopyTo(ba, 0);
string httpRequest = Encoding.ASCII.GetString(ba, 0, ba.Length).ToUpper();
bool validRequest = false;
string instruction = string.Empty;
try
{
// Retrieve the HTTP text and version (e.g. "HTTP/1.1")
m_HTTPVersion = httpRequest.Substring(httpRequest.IndexOf("HTTP"), 8);
instruction = httpRequest.Substring(5, (httpRequest.IndexOf(" HTTP") - 5));
validRequest = (httpRequest.Substring(0, 3) == "GET");
}
catch { }
if (validRequest)
{
if (instruction.IndexOf("GETALLROOMS") != -1)
{
byte[] contentData = Encoding.UTF8.GetBytes("Hello World!");
int contentLength = contentData.Length;
string now = DateTime.Now.ToLongDateString();
StringBuilder txbuffer = new StringBuilder();
txbuffer.Append(m_HTTPVersion).Append(" 200 OK\r\n");
txbuffer.Append("Server:This Computer\r\n");
txbuffer.Append("Content-Type:text/xml\r\n"); // Mime type is always text/xml
txbuffer.Append("Last-Modified:").Append(now).Append("\r\n");
txbuffer.Append("Accept-Ranges:bytes\r\n");
txbuffer.Append("Connection:close\r\n");
txbuffer.Append("Content-Length:").Append(contentLength).Append("\r\n");
txbuffer.Append("\r\n");
String s = txbuffer.ToString();
byte[] headerData = Encoding.UTF8.GetBytes(s);
try
{
if (socket.Connected)
{
int bytesSend;
bytesSend = 0;
while (bytesSend < headerData.Length)
bytesSend += socket.Send(headerData, bytesSend, headerData.Length - bytesSend, SocketFlags.None);
bytesSend = 0;
while (bytesSend < contentData.Length)
bytesSend += socket.Send(contentData, bytesSend, contentData.Length - bytesSend, SocketFlags.None);
}
else
{
}
}
catch { }
}
}
}
catch { }
finally
{
try
{
//Thread.Sleep(5000);
socket.Shutdown(SocketShutdown.Both);
//Thread.Sleep(5000);
socket.Close();
}
catch { }
}
socket = null;
}
}
}
}
|
|
|
|
|
Not sure why that is happening. Is there a reason why you are sending data byte by byte? If you use a stream (for example, StreamWriter) then you can call the Flush method on it. Here is an example:
void Send()
{
NetworkStream ns = new NetworkStream(aSocket);
StreamWriter w = new StreamWriter(ns);
w.WriteLine(aString);
w.Flush();
}
When you write to the stream, the stream is sent over the network.
Let me know if further needed.
|
|
|
|
|
Hi CodingYoshi.
Just to make sure I have mentioned it, the program runs on the compact framework V2..
The streamwriter does not solve the problem. I have made this small console app, which does not use the sockets directly. It still closes the connection before all data is send, if I dont add a delay. To add a delay is not good enough for me...
The small program accepts a connection from e.g. iexplorer via standard http port 80. It replies any request... so just type ( http://ip/ ). The program replies with xml: Hello world!
In this exaple no socket communication is made directly...
Im I doing something really wrong? Really hope someone can help me!
Here is the code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.IO;
namespace TestNetworkConsoleApp
{
class Program
{
static void Main(string[] args)
{
TcpListener m_TCPServer;
try
{
m_TCPServer = new TcpListener(IPAddress.Any, 80);
m_TCPServer.Start();
TcpClient tcpClient = m_TCPServer.AcceptTcpClient();
tcpClient.LingerState = new LingerOption(true, 100);
if (tcpClient != null)
{
try
{
string content = Hello World!";
string now = DateTime.Now.ToLongDateString();
StringBuilder txbuffer = new StringBuilder();
txbuffer.Append("HTTP/1.1").Append(" 200 OK\r\n");
txbuffer.Append("Server:This Computer\r\n");
txbuffer.Append("Content-Type:text/xml\r\n"); // Mime type is always text/xml
txbuffer.Append("Last-Modified:").Append(now).Append("\r\n");
txbuffer.Append("Accept-Ranges:bytes\r\n");
txbuffer.Append("Connection:close\r\n");
txbuffer.Append("Content-Length:").Append(content.Length).Append("\r\n");
txbuffer.Append("\r\n");
txbuffer.Append(content);
String s = txbuffer.ToString();
try
{
using (NetworkStream stream = tcpClient.GetStream())
{
StreamWriter w = new StreamWriter(stream);
w.Write(s);
w.Flush();
//Thread.Sleep(2000);
}
}
catch
{
}
}
catch
{
}
}
}
catch { }
}
}
}
|
|
|
|