SecurityA.dll实现
来源:互联网 发布:台湾误射导弹 知乎 编辑:程序博客网 时间:2024/06/06 01:31
public class SecurityA{ //extern修饰符支持在外部实现方法 //外部修饰符的常见方法是在使用Interop 服务调入非托管代码时与 DllImport 属性一起使用; //方法还必须声明为 static [DllImport("securityA.dll")] static extern IntPtr DeCode(IntPtr source, IntPtr key); [DllImport("securityA.dll")] static extern IntPtr EnCode(IntPtr source, IntPtr key); public string enCrypt(string source,string key) { string output = string.Empty; try { //转换为基本类型 IntPtr: 用于表示指针或句柄的平台特定类型。 IntPtr ptrIn = Marshal.StringToHGlobalAnsi(source); IntPtr ptrInKey = Marshal.StringToHGlobalAnsi(key); IntPtr ptrRtn = EnCode(ptrIn, ptrInKey); output = Marshal.PtrToStringAnsi(ptrRtn); } catch(Exception e) { throw e; } return output; } public string deCrypt(string source, string key) { string strRtn = string.Empty; try { IntPtr ptrIn = Marshal.StringToHGlobalAnsi(source); IntPtr ptrInKey = Marshal.StringToHGlobalAnsi(key); IntPtr ptrRtn = DeCode(ptrIn, ptrInKey); strRtn = Marshal.PtrToStringAnsi(ptrRtn); } catch(Exception e) { throw e; } return strRtn; }}
调用
//加密string strCode = sa.enCrypt("test".ToString(),strKey);//解密string strDeCode = sa.deCrypt(strCode, strKey);
阅读全文
0 0
- SecurityA.dll实现
- Narrator.dll 的实现
- loadrunner 调用dll实现
- DLL中实现对话框
- QueueUserApc实现DLL注入
- 日志DLL实现
- VC++实现DLL注入
- C++实现DLL注入
- DLL编程实现
- DLL 实现单元
- dll实现进程通信
- dll库的实现
- C++ DLL库实现
- 实现DLL内存补丁,DLL劫持技术
- Visual C++DLL编程实现
- Visual C++DLL编程实现
- Dll中实现模式对话框
- 实现Dll的延迟加载
- hive 优化点
- vc中GetDlgItem用法
- 如何停止Monkey测试
- bmp图片处理简单总结
- oracle中rownum和row_number()
- SecurityA.dll实现
- mac 安装配置ndk环境
- Java平台体系:组成结构 运行机制 JRE/JDK/OpenJDK Java SE/EE/ME Java优点
- 解决VMwareTools在Ubuntu下经常失效的问题
- Http模拟请求工具类
- JavaScript入门
- c实现无头结点单链表
- 最近点对问题——分治
- 例程 【C++】MFC 创建对话框,实现对“学生课程成绩”的管理