Integer-6ren">
gpt4 book ai didi

mysql - 从 ASP.NET 网页中的 "MySQL"获取 AES_DECRYPT 值

转载 作者:行者123 更新时间:2023-11-29 23:40:04 27 4
gpt4 key购买 nike

我的“MySQL 连接”在 ASP.NET 中完美运行

我可以完美地在数据库中获取和插入值

当我想从下表获取密码值时出现问题

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 mobile_no=@z2", 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 mobile_no=@z2", 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

关于mysql - 从 ASP.NET 网页中的 "MySQL"获取 AES_DECRYPT 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26202881/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com