Click here to Skip to main content
15,884,176 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

Password Storage: How to do it.

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
7 May 2011CPOL 6.7K   3   1
I think it has error, for example:A user is:string userId = "OriginalGriff"; string password = "NotMyPassword";And other user is:string userId = "Original"; string password = "GriffNotMyPassword";Problem to store two user.My idea is:private static...
I think it has error, for example:

A user is:
C#
string userId = "OriginalGriff";
            string password = "NotMyPassword";

And other user is:
C#
string userId = "Original";
            string password = "GriffNotMyPassword";

Problem to store two user.

My idea is:
C#
private static byte[] GetSHA1(string userID, string password)
            {
            SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
            byte[] hashedPassword = sha.ComputeHash(System.Text.Encoding.ASCII.GetBytes(userID);
            hashedPassword += sha.ComputeHash(System.Text.Encoding.ASCII.GetBytes(password);
            return sha.ComputeHash(hashedPassword);
            }

Thanks.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Vietnam Vietnam
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalit will show error as operator += cannot be applied to byte[... Pin
nilu1613-May-11 8:59
nilu1613-May-11 8:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.