调用一个自己写的c++的 dll,结果出现问题提示如下:“System.AccessViolationException”类型的未经处理的异常出现在 BidingSystem_Client.exe 中。其他信息: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。--------------------------------------------
c#
[DllImport("PEKS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
//对明文进行加密
static extern void Enc(string plain);----------------------------------------------
c++
void Enc(string plain)
{
//模拟上传文件加密
//加密文件
char aes_key[33];
Miracl precision(16,0); ECn point_key;
miracl *mip=&precision; point_key.iszero();
aes_set(point_key, aes_key);//准备好aes的密钥,点密钥为point_key, 字符串密钥为aes_key
int len = plain.length();
string name = plain.substr(0, len - 4); //获得去掉后缀的文件名
string cipher ="ciphertext\\" + name + ".aes"; //获得密文文件存储路径
plain = "plaintext\\" + plain;
aes_enc(plain, cipher, aes_key); //用aes加密
ifstream file("plaintext\\" + name + ".key");
string keyword;
while(getline(file,keyword, ' '))
{
char word[80]; //将string型的keyword转化为char*型的word
strcpy(word, keyword.c_str());
peks_enc(word, "ciphertext\\" + name +".kw"); //用PEKS加密关键词放在文件夹ciphertext中的.kw文件中
}
fIBE_enc(point_key, "ciphertext\\" + name + ".ak"); //加密对称密钥aes_key
file.close();
}求各位大神的解答
c#
[DllImport("PEKS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
//对明文进行加密
static extern void Enc(string plain);----------------------------------------------
c++
void Enc(string plain)
{
//模拟上传文件加密
//加密文件
char aes_key[33];
Miracl precision(16,0); ECn point_key;
miracl *mip=&precision; point_key.iszero();
aes_set(point_key, aes_key);//准备好aes的密钥,点密钥为point_key, 字符串密钥为aes_key
int len = plain.length();
string name = plain.substr(0, len - 4); //获得去掉后缀的文件名
string cipher ="ciphertext\\" + name + ".aes"; //获得密文文件存储路径
plain = "plaintext\\" + plain;
aes_enc(plain, cipher, aes_key); //用aes加密
ifstream file("plaintext\\" + name + ".key");
string keyword;
while(getline(file,keyword, ' '))
{
char word[80]; //将string型的keyword转化为char*型的word
strcpy(word, keyword.c_str());
peks_enc(word, "ciphertext\\" + name +".kw"); //用PEKS加密关键词放在文件夹ciphertext中的.kw文件中
}
fIBE_enc(point_key, "ciphertext\\" + name + ".ak"); //加密对称密钥aes_key
file.close();
}求各位大神的解答
解决方案 »
- 请问如何将项目中所有的DataGridView样式统一?(颜色等属性)
- 打开文件时只激活一个实例,文件在第一个实例中打开,求思路~~~
- 一个关于Action的问题
- 十几万数据使用ROW_NUMBER() OVER查询很慢
- 请教如何将查询条件保存到数据库或其他地方,供重复调用,不用每次都要手动一一输入查询条件?
- Treeview 点击该节点的事件是什么,怎样获取该节点的值?
- 菜鸟求救!关于winform TextBox控件中文本的显示问题?
- 调查, 看看大家最近都在用什么报表控件,分享一下, 来者有分。。。
- 怎么得到指定磁盘下所有的文件夹
- C# 操作word文档日期格式问题
- C#中我有一个界面,界面上有一个pictureBox控件,我想把这个控件上的图片存到数据库
- 提单时获取org.apache.struts.taglib.html.TOKEN
http://hi.baidu.com/meng7782002/blog/item/74c15fee4d2d7fc8b31cb190.html
我进入dll中进行调试,发现在c#传过去的string参数进入dll中以后就变了,并非原本的string
这是什么情况?代码还是上面那个