Geeks With Blogs
Guilherme Cardoso, Blog EN .NET geek

When we are dealing with more sensitive data and important as a keyword, it is not appropriate at all stores them in database without encrypting for security reasons.  For this we use MD5
 MD5 is an algorithm that allow us to encript an string, but doesn't leave us desencrypt it (not sure if it is already possible, but at least I know there are many databases already having a record).

 The method below will return us a variable encrypted with md5. For example: md5_encriptar ( ");
  The result will be: 34efe85d338075834ad41803eb08c0df

This way we save tthese encrypted data into a database, and then to make comparisons we often use the method to compare with the records kept.

public string md5_encrypt(string md5)
            System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] bs = System.Text.Encoding.UTF8.GetBytes(md5);
            bs = x.ComputeHash(bs);
            System.Text.StringBuilder s = new System.Text.StringBuilder();
            foreach (byte b in bs)
            string password = s.ToString();
            return password;

Posted on Tuesday, May 25, 2010 4:06 AM | Back to top

Comments on this post: C # - a variable using the Encrypt md5

# re: C # - a variable using the Encrypt md5
Requesting Gravatar...

Please note that MD5 is a hashing, not an encryption algorithm!

Take a look at the following link in order to make clear the difference between encryption and hashing.

Left by Victor Hurdugaci on May 25, 2010 10:24 PM

Your comment:
 (will show your gravatar)

Copyright © Guilherme Cardoso | Powered by: