获取AES_DECRYPT值从ASP.NET网页“MySQL的”
问题描述:
我的“MySQL连接”是完全在ASP.NET获取AES_DECRYPT值从ASP.NET网页“MySQL的”
工作我可以在数据库中插入值完全
的问题时,当我想从下表得到一个密码值
The Table has columns as,
ID->Integer
name->Varchar
mobile_no->VarChar
password->blob
Password column gives me problem
MySqlCommand cmd2=new MySqlCommand("SELECT AES_DECRYPT(password,'qwerty') FROM mytable1 where [email protected]", connection);
cmd2.Parameters.AddWithValue("@z2", TextBox1.Text);
String pass = cmd2.ExecuteScalar().ToString();
The 3rd line is giving me problem.
I want to compare this "pass" with ""Textbox2.text""
OR
I want to display that password on webpage (just fro try)
i.e., ""Label1.text=pass""
Its displaying this on Label...... ""System.Byte[] ""
答
尝试这样的:
MySqlCommand cmd2=new MySqlCommand("SELECT AES_DECRYPT(password,'qwerty') FROM mytable1 where [email protected]", connection);
cmd2.Parameters.AddWithValue("@z2", TextBox1.Text);
//prepare adapter to run query
adapter = new MySqlDataAdapter(cmd2);
DataTable Dt = new DataTable();
//get query results in DataTable
adapter.Fill(Dt);
string pass = Dt.Rows[0][0].ToString();
// your password contains Byte array as You said it is showing System.Byte[]
//You should convert it /Decode it into proper Plain text
编辑 取决于你的编码,你可以尝试这样的
string result = System.Text.Encoding.Default.GetString(pass);
string result = System.Text.Encoding.UTF8.GetString(pass);
//dispaly result on label
我创建的每个所需的连接,适配器和其他一切需要.... 我刚才把我的代码总之.... 但如果我按照精确的代码......然后还.... “通行证”将包含“System.Byte []”,而不是现在更新原有passowrd – 2014-10-05 13:23:09
尝试 – 2014-10-05 13:26:53
确定让我来试试 给我5分钟 – 2014-10-05 13:29:15