Text processing in Nodejs and PHP

I have two functions in php and javascript (nodejs) and both must give same result, but they didnt.

Why they give different result?

PHP:

base64_encode(sha1($string,1));

Javascript:

new Buffer(require("crypto").createHash("sha1").update(string,"utf8").digest("hex")).toString("base64");

Javascript version of function is wrong. I used this:

require("crypto").createHash("sha1").update(string,"utf8").digest("base64")