.net - Password hashing in a C# Windows app, absent ASP.NET's FormsAuthentication? -


my win form app doesn't seem formsauthentication, i'm totally new hashing convert welcome. thanks.

//write hash protected textbox tbpassword; protected literal lihashedpassword;  {   string strhashedpassword = formsauthentication.hashpasswordforstoringinconfigfile(tbpassword.text, "sha1");   lihashedpassword.text = "hashed password is: " + strhashedpassword;     }  //read hash string struserinputtedhashedpassword = formsauthentication.hashpasswordforstoringinconfigfile( tbpassword.text, "sha1"); if(struserinputtedhashedpassword == getusershashedpasswordusingusername(tbusername.text)) {   // sign-in successful } else {   // sign-in failed } 

using system.security.cryptography;  public static string encodepasswordtobase64(string password) {  byte[] bytes   = encoding.unicode.getbytes(password);    byte[] inarray = hashalgorithm.create("sha1").computehash(bytes);    return convert.tobase64string(inarray); }   

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -