http://www.php.net/manual/en/function.sha1.php
string sha1 ( string $str [, bool $raw_output = false ] )
If the raw_output option is set to TRUE, then instead of sha1 digest, a raw binary format of 20 is returned, otherwise the return value will be a hexadecimal number of 40 characters.
crypto = require("crypto");
console.log( new Buffer(crypto.createHash('sha1').update("some text").digest()).toString('base64') );
console.log( new Buffer(crypto.createHash('sha1').update("some text").digest("hex")).toString('base64') );
console.log( new Buffer(crypto.createHash('sha1').update("some text").digest("base64")).toString('base64') );
<?php
echo base64_encode(sha1("some text"));
echo base64_encode(sha1("some text", true));
?>
source
share