|
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.
|
|
|
|
|
That's because you are not doing the same thing in the C++ code as in the C# code. A class in C++ is not the same as in C#.
In the C++ code you are declaring an array of value types. The equivalent in C# would be to use a struct instead of a class.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: The equivalent in C# would be to use a struct instead of a class.
Even then, he'd have to write additional code to initialize the data members. The best overall solution is to use a generic list
using System.Collections.Generics;
namespace MyApp
{
class Program1
{
public class MyClass
{
private int m_data = -1;
public int Data
{
get { return m_data; }
set { m_data = value; }
}
public MyClass()
{
m_data = -1;
}
public MyClass(int data)
{
m_data = data;
}
}
static void Main(string[] args)
{
List<myclass> myClasses = new List<myclass>();
for (int i = 0; i < 12; i++)
{
MyClass myClass = new MyClass();
myClasses.Add(myClass);
}
}
}
}
</myclass></myclass>
"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
|
|
|
|
|
John Simmons / outlaw programmer wrote: Even then, he'd have to write additional code to initialize the data members.
That's true. In .NET there isn't any automatic construction going on without specifically asking for it.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa,
You were so right on about taking the structs approach, that got me exactly what I needed.
Thanks!!!
|
|
|
|
|
Be ware, though, that structs are a bit trickier than classes. You should read a bit on the recommendations on structure implementation:
MSDN: Structs[^]
MSDN: Value Type Usage Guidelines[^]
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I have a spread sheet of addresses that are in different formats.
Some of the addresses include cities or zip codes or floors or units, the formats for floor is "flr" or "floors" or "flrs"...I think you can see what I am getting at.
Is there a good parser library out there for use?
shwaguy
|
|
|
|