Rebuild node.js sha1 on terminal

I have a REST API in node.js. It can CRUD clients and saves an encrypted key like this:

// Let's sha the value.
var crypto = require('crypto')
  , shasum = crypto.createHash('sha1');

shasum.update(clientId + apiKey);

 // My hashed value:
shasum.digest('hex');

I want to have a shell script, that can perform the same WITHOUT touching the API.

I have tried this:

echo '1000apikey' | openssl sha1 -hex

But it results in a different hashed values (if clientId is 1000 and apiKey is "apikey"). Why's that?

echo '1000apikey' adds a newline character at the end of the string and that gets hashed too. Try echo -n '1000apikey' | openssl sha1 -hex.