4

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?

1 Answer 1

7

Change the import line to:

import * as crypto from 'crypto';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.