首先说说php和MySQL的md5函数,例如:
md5(“testing”) = “ae2b1fca515949e5d54fb22b8ed95575″;
这个和Python的 hexdigest() 函数结果是一样的
>>> md5(“testing”).hexdigest()
‘ae2b1fca515949e5d54fb22b8ed95575′
在LDAP里怎么表示的呢?
dn: cn=md5user,dc=my,dc=example,dc=com
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: md5user
description: MD5USER
userPassword: {MD5}CgIBDAUFBA4NBAsCCA0FBw==]
怎么得到的呢?
我们研究 字符串 testing 的 MD5 字串:ae 2b 1f ca 51 59 49 e5 d5 4f b2 2b 8e d9 55 75
首先隔一个字符提取一个字符,得到一个新的字符串,例如:
ae 2b 1f ca 51 59 49 e5 d5 4f b2 2b 8e d9 55 75
得到:
a 2 1 c 5 5 4 e d 4 b 2 8 d 5 7
那么把每一位看成十六进制,转换成对应的ASCII字符,例如第一位的 a,十六进制是 \x0A,也就是个回车:\n,把转换后的ASCII字符连起来,那么我们可以得到一串字符,不可显示的:’\n\x02\x01\x0c\x05\x05\x04\x0e\r\x04\x0b\x02\x08\r\x05\x07′