在C#,C ++,W32 api中加密 [英] Crypting in C#, C++, W32 api

查看:60
本文介绍了在C#,C ++,W32 api中加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的专家

出于教育目的,我正在尝试解密加密文本。此文本由.net使用PasswordDeriveBytes和RijndaelManaged加密。由.net加密意味着我们已经给出:

passPhrase

saltValue

hashAlgorithm(在我的情况下为SHA)

passwordIterations

initVector

keySize



我的目标:我正在尝试仅使用密码来解密密文基本的W32 Api使用纯c ++,没有任何帮助,很好的MS / VS支持(在VS / .net的完全支持的帮助下解密文本很简单且有效)。



我现在面临更大的问题,特别是野兽PasswordDeriveBytes。我不知道它到底在做什么,所以我试着一步一步地解决这个问题。经过谷歌搜索后,我的计划是:

我发现

mono / PasswordDeriveBytes.cs at effa4c07ba850bedbe1ff54b2a5df281c058ebcb·mono / mono·GitHub [ ^ ]

上面的链接I希望我在c#中找到PasswordDeriveBytes的源代码,我可以或多或少地转移到c ++。



但我在公共覆盖字节中遇到错误信息[] GetBytes(int cb)第243行(在上面的链接中),消息哈希在指定状态下无效。



最后我的希望/问题是,有人在这方面有一些相似的经验,可以给我一个暗示,最好是一个c ++的链接 - PasswordDeriveBytesfor dummies :)



我需要提一下我对这个加密内容没有基本知识:(



对不起我的问题和我的英语

提前谢谢。

问候



我尝试过:



如上所述.................... ........................

Dear experts
For educational purposes I'm trying to decrypt an encrypted text. This text is encrypted by .net using PasswordDeriveBytes with RijndaelManaged. Encrypted by .net means we have given:
    passPhrase
    saltValue
    hashAlgorithm (SHA in my case)
    passwordIterations
    initVector
    keySize

My target: I'm trying to decrypt the cipher text using only the basic W32 Api using pure c++ without any help the nice MS/VS support (decrypting the text by the help of full support of VS/.net is easy and works).

I'm facing now bigger problems especally with the "beast" "PasswordDeriveBytes". I have no idea what it is really doing, so I try to solve this part step by step. After googling hours my plan was/is:
I found
mono/PasswordDeriveBytes.cs at effa4c07ba850bedbe1ff54b2a5df281c058ebcb · mono/mono · GitHub[^]
the above link I hoped I found source code for "PasswordDeriveBytes" in c# which I can more or less easy transfer to c++.

But I stuck with an error message in "public override byte[] GetBytes(int cb)" line 243 (in the above link) with the message "Hash is not valid in the specified state.".

Finally my hope/question is, somebody has some similar experience in this and can give me a hint ir in best case a link for a c++ - "PasswordDeriveBytes" for dummies :)

I need to mention I' have no basic knowledge about this crypting stuff :(

Sorry for the cyrptic question and my english
Thank you in advance.
Regards

What I have tried:

Described above.。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

推荐答案

这篇博客文章 [ ^ ]描述了该课程的作用。它本质上是PBKDF1的一个实现,它可能是一个更好的搜索术语来查找C ++实现。



然而,文档 [ ^ ]说它正在使用 PBKDF1的扩展名。如果不确切知道扩展是什么,你可能很难匹配输出。



如果你可以切换.NET代码使用 Rfc2898DeriveByes [ ^ ]相反,这将使您的生活更简单。它是PBKDF2的直接实现,不涉及扩展。



或者,这个StackOverflow答案 [ ^ ]声称是一个工作 PasswordDeriveBytes 的单声道代码的翻译,尽管仅限于SHA1算法。
This blog post[^] describes what the class is doing. It's essentially an implementation of PBKDF1, which might be a better search term to find a C++ implementation.

However, the documentation[^] says it's using an extension of PBKDF1. Without knowing exactly what that extension is, you'll probably struggle to match the output.

If you could switch the .NET code to use Rfc2898DeriveByes[^] instead, that would make your life simpler. It's a straight implementation of PBKDF2, with no extensions involved.

Alternatively, this StackOverflow answer[^] claims to be a working translation of the Mono code for PasswordDeriveBytes, albeit limited to the SHA1 algorithm.


这篇关于在C#,C ++,W32 api中加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆