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?
CodePudding user response:
Change the import line to:
import * as crypto from 'crypto';