ximalangyashan 2022-08-12 20:59 采纳率: 98.9%
浏览 27
已结题

C#反编译找到解密方法,怎么使用这个方法解密数据?

public void DesDecrypt()
{
byte[] rgbIV = new byte[]
{
18,
52,
86,
120,
144,
171,
205,
239
};
try
{
byte[] bytes = Encoding.UTF8.GetBytes(this._decryptKey.Substring(0, 8));
DESCryptoServiceProvider descryptoServiceProvider = new DESCryptoServiceProvider();
byte[] array = Convert.FromBase64String(this._inputString);
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream, descryptoServiceProvider.CreateDecryptor(bytes, rgbIV), CryptoStreamMode.Write);
cryptoStream.Write(array, 0, array.Length);
cryptoStream.FlushFinalBlock();
Encoding encoding = new UTF8Encoding();
this._outString = encoding.GetString(memoryStream.ToArray());
}
catch (Exception ex)
{
this._noteMessage = ex.Message;
}
}


密文64Cic1ERUP9n2OzxuKl9Tw==
盐LIywB/zHFDTuEA1LU53Opg==

  • 写回答

2条回答 默认 最新

  • CSDN专家-showbo 2022-08-12 21:01
    关注

    这个是类的方法,可以建立属性_inputString【密文】_outString【明文】,_noteMessage【出错时的错误信息】,_decryptKey【密钥】,解密得到明文admin5566,示例如下

    
    using System;
    using System.Text;
    using System.Security.Cryptography;
    using System.IO;
    namespace Demo
    {
        public class Des
        {
            /// <summary>
            /// 密文
            /// </summary>
            public string _inputString { get; set; }
     
            /// <summary>
            /// 明文
            /// </summary>
            public string _outString { get; set; }
            /// <summary>
            /// 出错时的错误信息
            /// </summary>
            public string _noteMessage { get; set; }
            /// <summary>
            /// 密钥
            /// </summary>
            public string _decryptKey { get; set; }
            public void DesDecrypt()
            {
                byte[] rgbIV = new byte[]
                {
                    18,
                    52,
                    86,
                    120,
                    144,
                    171,
                    205,
                    239
                };
                try
                {
                    byte[] bytes = Encoding.UTF8.GetBytes(this._decryptKey.Substring(0, 8));
                    DESCryptoServiceProvider descryptoServiceProvider = new DESCryptoServiceProvider();
                    byte[] array = Convert.FromBase64String(this._inputString);
                    MemoryStream memoryStream = new MemoryStream();
                    CryptoStream cryptoStream = new CryptoStream(memoryStream, descryptoServiceProvider.CreateDecryptor(bytes, rgbIV), CryptoStreamMode.Write);
                    cryptoStream.Write(array, 0, array.Length);
                    cryptoStream.FlushFinalBlock();
                    Encoding encoding = new UTF8Encoding();
                    this._outString = encoding.GetString(memoryStream.ToArray());
                }
                catch (Exception ex)
                {
                    this._noteMessage = ex.Message;
                }
            }
        }
        class Program
        {
            static void Main(string[] args)
            {
                var d = new Des { _inputString= "64Cic1ERUP9n2OzxuKl9Tw==", _decryptKey= "LIywB/zHFDTuEA1LU53Opg==" };
                d.DesDecrypt();
                Console.WriteLine(d._outString);
     
                Console.ReadKey();
            }
        }
    }
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 8月21日
  • 已采纳回答 8月13日
  • 创建了问题 8月12日

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)