问题描述
这是我在 hudson / users / me / config.xml中看到的
:
[...]
<hudson.security.HudsonPrivateSecurityRealm_-Details>
<passwordHash>mEDUyJ:0c9e6f2556b9b3a0b9e9046c21490422b4a54877f057b527b2c0bd4dc83342d5</passwordHash>
</hudson.security.HudsonPrivateSecurityRealm_-Details>
[...]
算法是什么(如果是SHA1,那么是什么 mEDUyJ
前缀)?例如,如何在PHP中获取此哈希值?
What is the algorithm (if SHA1, than what is the mEDUyJ
prefix)? How can I get this hash in PHP, for example?
推荐答案
在 class(更具体地说, PasswordEncoder
内部类)。
考虑你的例子:
mEDUyJ:0c9e6f2556b9b3a0b9e9046c21490422b4a54877f057b527b2c0bd4dc83342d5
前缀( mEDUyJ
)实际上是六个字母的盐。 salt可以是大写字母和小写字母的任意六个字母的排列。
The prefix (mEDUyJ
) is actually a six-letter salt. A salt can be any six-letter permutation of uppercase letters and lowercase letters.
Hudson使用。更具体地说,它使用该库的类。它基本上是这样做的:
Hudson uses the Acegi Security library. More specifically, it uses that library's ShaPasswordEncoder
class. It's basically doing this:
String salt = generateSomeSixLetterSalt() // Fictional function
String passwordHash = salt + ":" + new ShaPasswordEncoder(256).encodePassword(password, salt);
查看 ShaPasswordEncoder
的源代码后,你发现它基本上是这样做的:
Once you view the source code for ShaPasswordEncoder
, you find this it's essentially doing this:
// Fictional functions ahead...
String salt = generateSomeSixLetterSalt()
String passwordHash = salt + ":" + hex_encode(sha256_hash(utf8_encode(password + "{" + salt + "}")))
这篇关于Hudson使用什么密码加密?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!