开发者

Adding \000 to each char in a password string

Why would one do this.

for ($i = 0; $i < $len; $i++) {
    $unicodepassword .= "{$passwd{$i}}\000";
}

Context: This is a password set when creating or modifying a user in Active directory. We are rewriting some ancient code and nothing works without this. Making changes in our LDAP does not require this kind of "encoding".

Also the result of this exercise is called 开发者_Python百科"unicodepassword", seems strange to me.


Also the result of this exercise is called "unicodepassword", seems strange to me.

This is actually a simple conversion from ASCII to UTF-16 (little endian). For characters > #127, it will translate into a unicode code point whose value is the same as ord($passwd{$i}) (so it will depend on the encoding of the original password).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜