C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Encryption »

Password Encription c#


Posted Date: 09 Oct 2008    Resource Type: Code Snippets    Category: Encryption
Author: Mathew PhilipMember Level: Gold    
Rating: 1 out of 5Points: 7



While storing the passwords we are requested to store it in an encripted format, so the the direct database viewers will not read the password from the database

See an example
namespace using


using System.Security.Cryptography;


Sample method to encript the password


public string Encript(string password)
{
System.Security.Cryptography.MD5CryptoServiceProvider objCript =
new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] bs = System.Text.Encoding.UTF8.GetBytes(password);
bs = objCript.ComputeHash(bs);
System.Text.StringBuilder s = new System.Text.StringBuilder();

foreach (byte b in bs)
{
s.Append(b.ToString("x2").ToLower());
}
password = s.ToString();
return password;
}


Later in the user login time we will again encript the password and will compare it with the encripted password in the database. Thats WE WILL NOT DECRIPT IT.



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Password encription  .  Encription  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Encryption and Decryption of password
Previous Resource: Code for encrypting and decrypting Input String
Return to Discussion Resource Index
Post New Resource
Category: Encryption


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use