c# - Retrieve a hashed password -


i make password become not stored original text in database. while want retrieve , check between entered password in database, error appears

value cannot null

on line of code:

string verifyhashedpassword = convert.tostring(crypto.verifyhashedpassword(_registration.hashedpassword, this.textbox2.text)); 

here code using login:

  string connectionstring = @"provider=microsoft.ace.oledb.12.0;data  source=..\db1.accdb";    registration _registration = new registration();    private void checkuserdatabase(object sender, eventargs e)     {         using (oledbconnection conn = new oledbconnection(connectionstring))         {             string query = "select [username], [password], [usertype], [userstore] [member] [username] = @username , [password] = @password";              string verifyhashedpassword = convert.tostring(crypto.verifyhashedpassword(_registration.hashedpassword, this.textbox2.text));              conn.open();              using (oledbcommand cmd = new oledbcommand(query, conn))             {                 cmd.parameters.add("@username", system.data.oledb.oledbtype.varchar);                 cmd.parameters["@username"].value = this.textbox1.text;                  cmd.parameters.add("@password", system.data.oledb.oledbtype.varchar);                 cmd.parameters["@password"].value = verifyhashedpassword;                  using (oledbdatareader dreader = cmd.executereader())                 {                     if (dreader.read())                     {                         userinformation.currentloggedinuser = (string)dreader["username"];                         userinformation.currentloggedinusertype = (string)dreader["usertype"];                         userinformation.currentloggedinuserstore = (string)dreader["userstore"];                     }                      else                     {                         recursivecleartextboxes(this.controls);                     }                      dreader.close();                     conn.close();                 }             }         }     } 

here code registration:

    string connectionstring = @"provider=microsoft.ace.oledb.12.0;data source=..\db1.accdb";      private void adddatabase(object sender, eventargs e)     {            string query = "insert [member] ([username], [password], [usertype],              [userstore]) values (@username, @password, @usertype, @userstore)";              string hashedpassword = crypto.hashpassword(this.textbox2.text);              oledbconnection _conn = new oledbconnection(connectionstring);              _conn.open();              using (oledbcommand cmd = new oledbcommand(query, _conn))             {                 cmd.parameters.add("@username", system.data.oledb.oledbtype.varchar);                 cmd.parameters["@username"].value = this.textbox1.text;                  cmd.parameters.add("@password", system.data.oledb.oledbtype.varchar);                 cmd.parameters["@password"].value = hashedpassword;                  cmd.parameters.add("@usertype", system.data.oledb.oledbtype.varchar);                 cmd.parameters["@usertype"].value = this.textbox3.text;                  cmd.parameters.add("@userstore", system.data.oledb.oledbtype.varchar);                 cmd.parameters["@userstore"].value = this.textbox4.text;                  cmd.executenonquery();                  dialogresult _dialogresult = messagebox.show("added successfully", "success", messageboxbuttons.ok);                  if (_dialogresult == dialogresult.ok)                 {                     this.hide();                      this.close();                 }             }         }     } 

any help?

your answer appreciated!

thank you


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -