Encrypting string to Sha1 in Homeyscript

Hi,
Anyone knows how to encrypt a string variable to Sha1?
When encrypting to Base64 I use .toString(‘base64’), so wonder if there are anything similar available for Sha1 encryption?
Hope someone can guide me :slight_smile:
Thx in advance

const crypto = (this.constructor.constructor('return process.mainModule.require')())('crypto');

function hash(string) {
  const hasher = crypto.createHash('sha1');
  hasher.update(string);
  return hasher.digest('hex');
}

console.log( hash('hello world') )

Of course, SHA1 isn’t an encryption algorithm but a hash function (and Base64 is an encoding method) :wink:

It worked :slight_smile:

First thank you - you saved my day.
Second thanks for super fast reply…
and third, you learned me something new today :slight_smile: