|
|
ILDASM.EXE comes with Visual Studio.
Pits fall into Chuck Norris.
|
|
|
|
|
Hello everyone,
I am new to how to use C# to calculate hash value for a string. I want to check we normally use MD5CryptoServiceProvider.ComputeHash?
As described here?
http://support.microsoft.com/kb/307020/en-us
thanks in advance,
George
|
|
|
|
|
What's wrong with the gethash method that's built in ?
You can use any method you like, but I would agree you should use a built in crypto class, if you want something other than the built in method.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks Christian,
Do you have a sample for gethash? I can not find one from MSDN or Google.
regards,
George
|
|
|
|
|
GetHashCode is a method on all objects in .NET
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks Christian,
Question answered. I searched for "gethash" other than "GetHashCode" before, so no samples are found.
have a good weekend,
George
|
|
|
|
|
George_George wrote: use MD5CryptoServiceProvider.ComputeHash?
MD5 is weak. There are many algorithms available to get the original string from a MD5 hash. You may consider using SHA . There are different types like SHA256 , SHA384 , SHA512 etc. Here is an example which uses SHA512 to hash.
string stringToBeHashed = "Hello";
byte[] bytesToBeHashed = Encoding.ASCII.GetBytes(stringToBeHashed);
SHA512 sha = new SHA512Managed();
byte[] hashedBytes = sha.ComputeHash(bytesToBeHashed);
string hashedString = Convert.ToBase64String(hashedBytes); Hope this helps
|
|
|
|
|
Cool, N a v a n e e t h!
regards,
George
|
|
|
|
|
It depends on whether you need a cryptographically strong hash or not.
.GetHashCode is fast and quite weak (its easy/more likely to find something with the same hash).
The CSPs are a lot slower but generate much stronger hashes.
|
|
|
|
|
Thanks Mark,
CSP you mean Crypto Service Provider? Or? For example, C# class do you refer?
regards,
George
|
|
|
|
|
Yep the crypto service providers.
|
|
|
|
|
Thanks Mark,
Cool!
regards,
George
|
|
|
|
|
Hi,
I am trying to send email using c# and the code from my research is here:
MailMessage logMailMessage = new MailMessage();
logMailMessage.To = "email1@hotmail.com";
logMailMessage.Subject = "Subject is here ";
logMailMessage.From = "email2@hotmail.com";
logMailMessage.Attachments.Add(new MailAttachment(Settings.LogFile));
SmtpMail.Send(logMailMessage);
What I don't know is how does the machine know the password of email address that I am using to send the email? pls help thk
|
|
|
|
|
YAI wrote: hat I don't know is how does the machine know the password of email address that I am using to send the email?
It doesn't. You have to supply it somehow. That's if your SMTP server (which, BTW, you didn't specify anywhere) requires a username/password to send a message.
|
|
|
|
|
It's usually done with anonymous SMTP, if your SMTP server allows such.
|
|
|
|
|
Thank for the replies. And How can I know whether Smtp server allows that? If I want to check whether the sending is successful, is putting try catch with catch(Exception ex) enough?
|
|
|
|
|
Most don't any more. For instance, AT&T changed their servers a few weeks ago to disallow the practice.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Those mail are send via SMTP. if you want to send mail from your accout then you have to set the NetworkCredential For that. which contain your name, password and domain
Best Regards
-----------------
Abhijit Jana
Microsoft Certified Professional
"Success is Journey it's not a destination"
|
|
|
|
|
Thank everyone for helps
|
|
|
|
|
Hi, I'm using the PrintPreviewDialog class to print a PrintDocument object. I'm wondering how to bring up a print options dialog after the print button on the preview screen is hit.
Can't seem to find a way to "get in between" the PrintPreviewDialog's print button and the actual printing.
|
|
|
|
|
Hi,
printing is a complex matter if you ask me, I got the things working that I needed
but had to fight a lot to get some of the details right.
AFAIK the printer selection should occur before you go to print preview; print preview
should show things exactly as the printer will print them, so IMO it needs to know the
printer characteristics.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
I am developing a add-in and I've planned to write an article about it, but I am facing VERY annoying problem that I can't figure out.
I've loaded up virtual machine to test a real time behavior of the add-in and notice this problem.
When I am run add-in (F5) from it's project, context menu items adds to the menu of the code window and aspx context CommandBars.
After I build a setup (containing .dll, .addin file and adding proper value in registry) and opening a project, add-ins main window loads, but context menus don't.
I have two folders in the installation folder.
One is for VS 2005 and other for VS 2008.
First time, I was testing with only one folder (for VS 2005) and context menu items was working.
Further on, I've added second folder to the setup project, build it and send to to virtual machine for testing.
Context menus didn't show up.
Ever since then I was unable to get them work.
I also though that setup is building with wrong .dll, but I am pretty sure that's not the case.
To exclude that possibility, I've manually added .dll file to the install folder.
Add-ins main window works on both Visual Studios.
Please help!
This is driving me crazy!!!
And sorry if I was confusing...
|
|
|
|
|
Hi,
I must be missing something very basic so please excuse the seemingly simplicity of this question:
Question: How does one create an array of classes in C# without having to call the constructor for each elment in the array.
Example: In C++ one would do the following:
<br />
class MyClass<br />
{<br />
public:<br />
int myData;<br />
<br />
MyClass::MyClass()<br />
{<br />
myData= 1;<br />
}<br />
};<br />
In main:
void main()<br />
{<br />
<br />
MyClass myVar[12];<br />
<br />
cout << myVar[0].myData;
}<br />
For C# I try this (ignore any syntax errors that may exists):
<br />
void Main()<br />
{<br />
<br />
MyClass[] myVar = new MyClass[12];<br />
<br />
Console.WriteLine("{0}", myVar[0].myData);
<br />
}
Can this be done in C#, if so, how?
-Joe
|
|
|
|
|
Hi Joe,
in C# you can not; you need to create the array as in your statement
MyClass[] myVar = new MyClass[12];
but this gives 12 null references.
Now you may or may not load the array with an explicit loop containing myVar[i]=new MyClass();
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|