c# - Asp.net password encryption and decryption with salt -


i trying pull encrypted password table receiving error:

system.data.sqlclient.sqlexception: conversion failed when converting nvarchar value '84p37u29dna08xhudv+bhq==' data type int.

where value encrypted password. don't understand why there error. code breaks @ line: dataadapter.fill(dataset);

protected bool attemptlogin(string username, string password)     {         bool validlogin = false;          string sql = "select users.username, passwords.password " +                      "from users inner join passwords on users.userid = passwords.password " +                      "where users.username = @username";         sqlcommand command = new sqlcommand(sql, dbconnection);         command.parameters.addwithvalue("@username", username);          sqldataadapter dataadapter = new sqldataadapter(command);          // set of tables (in instance, one)         dataset dataset = new dataset();         dataadapter.fill(dataset);         // first table in dataset         datatable table = dataset.tables[0];          // value of password (should in encrypted form)         string dbpassword = table.rows[0]["password"].tostring();          // decrypt password         string decryptedpassword = decrypttext("", dbpassword);         if (decryptedpassword.equals(password))         {             validlogin = true;         }          return validlogin;     } 

inner join passwords on users.userid = passwords.password

you're attempting join userid (int) password (nvarchar).


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -