小编Sit*_*uah的帖子

MySQL 中加密,C# 中解密

我在 MySQL 中加密了数据,将其存储为 BLOB,然后需要在 C# 中对其进行解密,但没有得到预期的结果。

MYSQL 中的 BLOB:

MySQL 中的 BLOB

这是我的结果:

结果

应该只是PD001KY6900430

这是我的 C# 代码

string ConnectionString = "Data Source=win-3doecchgfbt;Initial Catalog=DWH;User id=sa;Password=Password123;";
        using (SqlConnection connection = new SqlConnection(ConnectionString))
        {
            string query = "SELECT * FROM tb_investor";
            SqlDataAdapter adapter = new SqlDataAdapter();
            var command = new SqlCommand(query, connection);
            adapter.SelectCommand = command;

            DataTable dTable = new DataTable();

            adapter.Fill(dTable);
            for(var x =0; x < dTable.Rows.Count; x++)
            {
                var dr = dTable.Rows;

                byte[] accNoByte = (byte[])dr[x].ItemArray[1];

                byte[] key = mkey("satu");

                var rkey = BitConverter.ToString(key).Replace("-", ""); …
Run Code Online (Sandbox Code Playgroud)

php c# mysql encryption blob

4
推荐指数
1
解决办法
838
查看次数

标签 统计

blob ×1

c# ×1

encryption ×1

mysql ×1

php ×1