遇到使用.net framework编写的dll,里面有实现加解密方法。想要调用相关解密函数对字符串进行解密。
web.config文件中定义了数据库的连接信息。
内容是base编码的内容,不可直接解码。
在YHLBaseFunc.dll文件中,YHLBaseFunc.CryptManage类下存在Decrypto函数方法可以进行解密。
创建一个Program.cs文件,使用.net中的反射进行调用相关解密函数。
using System;
using System.Reflection;
namespace DecryptTextExample
{
class Program
{
static void Main()
{
// 加载DLL
string dllPath = "YHLBaseFunc.dll"; // 替换为实际的DLL路径
Assembly assembly = Assembly.LoadFrom(dllPath);
// 获取DecryptText方法
Type type = assembly.GetType("YHLBaseFunc.CryptManage");
MethodInfo method = type.GetMethod("Decrypto");
// 创建CryptManage实例
object cryptManageInstance = Activator.CreateInstance(type);
// 调用DecryptText方法
string encryptedText = "uiLEkqDCJIb9b/t6N0M9greoxsTEyvSIe+2PAARri/mI8E/Upi3ih6Kd79y2rVoyAMYT53zuoyQ25EwoW5NfCQ==";
object[] parameters = new object[] { encryptedText };
string decryptedText = (string)method.Invoke(cryptManageInstance, parameters);
// 输出解密结果
Console.WriteLine("Decrypted Text: \r\n" + decryptedText);
}
}
}
使用.net framework相关的SDK中的csc.exe进行编译。
用csc.exe Program.cs即可在本地生成相关exe程序。
相关dll文件: YHLBaseFunc.dll