Any one way Encryption Method better than MD5 ? (.NET)
I`m searching for an Encryption Method better than MD5. It must be one way encryption because I do not want to use keys in encry开发者_JAVA百科ption.
Basically MD5 is a Hashing algorithm not an encryption. you can use more stable SHA1
using(System.Security.Cryptography.SHA1 hash = System.Security.Cryptography.SHA1.Create())
{
System.Text.ASCIIEncoding encoder = new System.Text.ASCIIEncoding();
byte[] combined = encoder.GetBytes(str);
hash.ComputeHash(combined);
}
EDIT: answer to comments
System.Security.Cryptography.SHA1 Class
The hash is used as a unique value of fixed size representing a large amount of data. Hashes of two sets of data should match if the corresponding data also matches. Small changes to the data result in large, unpredictable changes in the hash.
The hash size for the SHA1 algorithm is 160 bits.
MD5 is not an encryption method, because you can not decrypt the message given its MD5 hash. It's a hashing algorithm: given an arbitrary message it computes its 'digest' (hence the algorithm name).
MD5 can be used as a means of signing messages, by computing the MD5-hash of the (message + shared secret) combination.
There are other hashing algorithms, for example SHA1
and SHA256
, you can use them in your code instead of MD5.
精彩评论