使用 wincrypt 解密数据文件。有麻烦了。示例显示 CBase64Utils?
我需要用 wincrypt 解密一些数据文件,但网上的例子很少。我发现的最可靠的例子是 此处。然而,这使用了各种类型,我似乎无法找到有关的信息(CBase64Utils、CString 等)。
我正在阅读最终的解决方案,试图理解这个过程,并得出这样的结论:
// 5. Determine the LENGTH of the BUFFER to hold the corresponding cyphertext.
CBase64Utils bu;
int ipszSourceLen = strlen(pszSource);
char *pszSource2 = bu.Decode(pszSource, &ipszSourceLen);
DWORD dwSourceLen = strlen(pszSource2); // Get the length of the input string.
DWORD dwDataLen = dwSourceLen;
BYTE* pTarget = NULL;
DWORD dwCryptDataLen = dwDataLen;
CryptEncrypt(hKey, 0, TRUE, 0, NULL, &dwCryptDataLen, dwDataLen);
这对我来说是纯中文的。有人能理解它并希望澄清一些浑水吗?谢谢
I need to decrypt some data files with wincrypt and examples are few and far between online. The most solid example I've found is here. However, this is using all sorts of types I cannot seem to find information about (CBase64Utils, CString, etc).
I am reading the final solution, trying to understand the process, and have come to this:
// 5. Determine the LENGTH of the BUFFER to hold the corresponding cyphertext.
CBase64Utils bu;
int ipszSourceLen = strlen(pszSource);
char *pszSource2 = bu.Decode(pszSource, &ipszSourceLen);
DWORD dwSourceLen = strlen(pszSource2); // Get the length of the input string.
DWORD dwDataLen = dwSourceLen;
BYTE* pTarget = NULL;
DWORD dwCryptDataLen = dwDataLen;
CryptEncrypt(hKey, 0, TRUE, 0, NULL, &dwCryptDataLen, dwDataLen);
This is pure chinese to me. Can anybody make sense of it and hopefully clear some muddy waters? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您链接的代码太糟糕了。看起来该家伙编写了他的加密方法,然后通过简单地复制和粘贴第一个方法并进行一些更改(但留下了加密过程中留下的大量代码)来编写了他的解密方法。如果它有效,我不会感到惊讶,只是它浪费时间和空间来做加密留下的无用工作(加上评论都是倒退的)。
由于 wincrypt 是一个 Microsoft 库,因此有很多示例 在 MSDN 上。由于 MSDN 示例(通常)写得很好并且注释也很好,因此它们应该更容易理解,因此我建议您查看它们。
The code you linked is horrible. It appears the fellow wrote his encrypt method, and then subsequently wrote his decrypt method simply by copying and pasting the first method and making a few changes (yet leaving a ton of code left over from the encryption process). I wouldn't be surprised if it works, it's just that it wastes time and space doing useless work left over from encryption (plus the comments are all backwards).
As wincrypt is a Microsoft library, there are plenty of examples over at the MSDN. As MSDN samples are (usually) well-written and well-commented, they should be much easier to understand, so I would recommend you look at them instead.