Convert SHA1 to base64

can someone help with this thing that is driving me crazy? on https://tomeko.net/online_tools/hex_to_base64.php?lang=en and https://base64.guru/converter/encode/hex

I want to get this output on my PHP script like the above sites----->afE/gGTQDVy64Mres5m26KbDMU4=

$str = '69F13F8064D00D5CBAE0CADEB399B6E8A6C3314E';
echo base64_encode($str);

but my output is-------->

NjlGMTNGODA2NEQwMEQ1Q0JBRTBDQURFQjM5OUI2RThBNkMzMzE0RQ==

Upvotes: 4

Views: 5217

Answers (1)

AaronJ
AaronJ

Reputation: 1170

Does echo base64_encode(hex2bin('69F13F8064D00D5CBAE0CADEB399B6E8A6C3314E')); work for you?

I tested this here http://sandbox.onlinephpfunctions.com/code/9715207a2edbf15ca54c89cbf9c79559bcfcd76e

Upvotes: 7

Related Questions