Reputation: 335
I have the following code that creates an encryption in PHP:
$password = "helloworld";
$passwordupper = strtoupper($password);
$passwordencode = mb_convert_encoding($passwordupper, 'UTF-16LE');
$passwordsha1 = hash("SHA1", $passwordencode);
$passwordbase64 = base64_encode($passwordsha1);
The instructions I have from the system I'm trying to connect to states:
The encoding process for passwords is: first convert to uppercase, then Unicode it in little-endian UTF 16, then SHA1 it then base64 encode it.
I think I'm doing something wrong in my code. Any ideas?
Upvotes: 0
Views: 128
Reputation: 335
Answer solved by Marc B above in comments:
sha1 hash can either be raw binary, or a base64-encoded string to begin with. e.g. $raw = sha1($string, true) v.s. $encoded = sha1($string). you'd better try both variants, because you may be double-base64-encoding.
Upvotes: 1