PHP
<?php
$string = base64_encode(sha1( 'ABCD' , true ) );
echo sha1('ABCD');
echo $string;
?>
Output:
fb2f85c88567f3c8ce9b799c7c54642d0c7b41f6
+y+FyIVn88jOm3mcfFRkLQx7QfY=
Python
import base64
import hashlib
s = hashlib.sha1()
s.update('ABCD')
myhash = s.hexdigest()
print myhash
print base64.encodestring(myhash)
Output:
'fb2f85c88567f3c8ce9b799c7c54642d0c7b41f6' ZmIyZjg1Yzg4NTY3ZjNjOGNlOWI3OTljN2M1NDY0MmQwYzdiNDFmNg==
Both the PHP and Python SHA1 works fine, but the base64.encodestring() in python returns a different value compared to base64_encode() in PHP.
What is the equivalent method for PHP base64_encode in Python?