Community discussion forum

Create Hashes - MD5, SHA1, SHA256, SHA384, SHA512

This is a comment thread discussing Create Hashes - MD5, SHA1, SHA256, SHA384, SHA512
  • 10 years ago

    This thread is for discussions of Create Hashes - MD5, SHA1, SHA256, SHA384, SHA512 .

  • 5 years ago

    For SHA1 and MD5 you can simply use:


    string hashedText = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("some text", "sha1");

  • 5 years ago

    To get the same result as the md5() function in PHP, use ASCIIEncoding!
    As in: ASCIIEncoding UE = new ASCIIEncoding();


    Another note:
    Yes, there is a simpeler way to do md5 and sha1, but if i have a class for SHA256, 384 and 512, I'd like to combine all of them into one not doing 512 with the class and sha1 with something else.

  • 5 years ago

    Note, the author wrote that the result of a Hash is unique.  This is NEVER the case for a hash function.  Hashes are consistent.  Given a hash function H and a value a, H(a) = H(a) (i.e., hashes aren't random in a way which varies invocation to invocation.


    But given a,b with a!=b it is not true that H(a) != H(b).  Indeed for any digest hash one can find a,b with a!=b and H(a) = H(b).


    BE WARNED.  Never hash something that is used as a primary key.  E.g., HASH passwords but never hash usernames.

  • 3 years ago

    Thanks a lot

  • 3 years ago

    Hi,

    I'm using SHA1 to hash the some code in vb.net(desktop app). but when i create SHA1 in PHP it doesn't match with the one i created with vb.net.I filtered out all the special chars in hash generated using vb.net (like =,+ etc).The hash thus trimmed out is only 20-22 chars but when i used php itz above 30. Pls help me

    Tom

  • 2 years ago
    Is it possible to hash files instead of text? I know I can do it with MD5 and SHA1 (with a FileStream and "System.Security.Cryptography.MD5CryptoServiceProvider" and "System.Security.Cryptography.SHA1CryptoServiceProvider")

    but when I tried generated any others it gave me a diffrent hash every time(SHA256,SHA384 and SHA512)...



  • 1 year ago

     Hi just like jitz I am struggling to realise a result that matches the SHA1 result when using php can anybody help clarify how to get the same result pls

  • 1 year ago

    Maybe you will find this post adds more light to the issue.

  • 1 year ago

    I'm sure you've found the answer by now, but in case anybody else is on the same quest, maybe this will help:

    Porting the Equivalent of PHP’s MD5 to .NET platform in C#

     

Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!