在托管程序中如何实现对数据加密

lllxy 2008-09-09 10:48:13
public string GetMD5(string sDataIn, string move)
...{
System.Security.Cryptography.MD5CryptoServiceProvider
md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] bytValue, bytHash;
bytValue = System.Text.Encoding.UTF8.GetBytes(move + sDataIn);
bytHash = md5.ComputeHash(bytValue);
md5.Clear();
string sTemp = "";
for (int i = 0; i < bytHash.Length; i++)
...{
sTemp += bytHash[i].ToString("x").PadLeft(2, '0');
}
return sTemp;
}

上面的代码是我在网络上找到的,我现在通过vc.net创建了一个windows的应用程序,我现在用到数据加密的功能,可是这段代码用不了,当我直接把这段代码拷贝到
程序中时,出现如下错误:
Form1.h(95): error C2144: syntax error : 'std::string' should be preceded by ':'
Form1.h(96): error C2230: 'GetMD5' : a member function of a managed class cannot return a non-managed class or struct 'std::basic_string<_Elem,_Traits,_Ax>' unless it is an aggregate

请问我应该如何才能编译成功,谢谢了.

...全文
128 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
真相重于对错 2008-09-10
  • 打赏
  • 举报
回复
这是c#语法,你需要改一下

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧