I have a PHP application in which passwords are stored in the database as the output of sha1 ($ password), which, apparently, is the hexadecimal representation of the binary SHA1 hash. (as I understand)
I would like to convert this to a format compatible with Apache.htpassword files, which must be a base64 encoded binary value or base64_encode output (sha1 ($ password, true)).
I found this topic: Convert base64'd SHA1 hashes to hashes ... which does the opposite of what I need to do and it works fine, I tried changing the order of the commands and using hex2bin instead of bin2hex, but this does not work:
Fatal error: call to undefined hex2bin () function in php shell code on line 1
Apparently this is not available until PHP 5.4, and this server is still located at 5.3.x http://php.net/manual/en/function.hex2bin.php
Here is the real problem. I really need to convert it to PERL, preferably only using standard built-in modules, so that everything is simple. I'm not sure why they use perl for this step, but I'm trying to edit one very small part of a larger application and don't want to change all this :)
To be clear, I am not trying to convert hexadecimal numbers to binary numbers. This is a hexadecimal representation of the binary value stored in perl "string" :)
Thanks in advance, Tommy
source share