in my typescript project I'm trying to get SHA1 Hash with the help of crypto module from nodejs.
import crypto from 'crypto';
console.log(crypto.createHash('sha1').update('message').digest('hex'));
but after running it, the only thing I get is
TypeError: Cannot read property 'createHash' of undefined
What am I missing? Is there a better way to get SHA1 hash in typescript?
Change the import line to:
import * as crypto from 'crypto';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With