C++ 解密使用 htpasswd 创建的密码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13328214/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 17:11:42  来源:igfitidea点击:

Decrypt password created with htpasswd

c++apacheubuntuencryptionapache2

提问by Mils

I created a protection for my web pages with apache2 in ubuntu. Now I am creating an application in c++ and I want it uses the same file that Apache2 uses for authentification, but my problem is that I don't know how to decrypt the password generated by apache2. (Maybe I need a key that is used for encryption).

我在 ubuntu 中使用 apache2 为我的网页创建了保护。现在我正在用 C++ 创建一个应用程序,我希望它使用 Apache2 用于身份验证的相同文件,但我的问题是我不知道如何解密 apache2 生成的密码。(也许我需要一个用于加密的密钥)。

Thank you.

谢谢你。

回答by Sani Singh Huttunen

.htpasswd entries are HASHES. They are not encrypted passwords. Hashes are designed not to be decryptable. Hence there is no way (unless you bruteforce for a loooong time) to get the password from the .htpasswd file.

.htpasswd 条目是HASHES。它们不是加密密码。散列被设计为不可解密的。因此没有办法(除非你蛮力很长时间)从 .htpasswd 文件中获取密码。

What you need to do is apply the same hash algorithm to the password provided to you and compare it to the hash in the .htpasswd file. If the user and hash are the same then you're a go.

您需要做的是将相同的散列算法应用于提供给您的密码,并将其与 .htpasswd 文件中的散列进行比较。如果用户和哈希相同,那么你就可以了。

回答by David Tonhofer