I stumbled upon a problem with the mcrypt library – when decoding (using DES and ECB mode) the encoded string is trailed with leading non-printalbe ASCII characters. So an encoded “mysecret1” becomes “mysecret1”.
Not shure what causes it, but i found a hack to get rid of those nasty low ASCII chars:
$password = preg_replace("/[\\x00-\\x1F]/", "", $password);
In the hope to serve more people the pain of fiddling with this, I’ll keep some programming-snipplets in english.
Situation: you have HEX codes and need binary
Solution:
function hex2bin ($hex) { return pack("H*", $hex); }