question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when i create jsSHA object

See original GitHub issue

I have react application. I have implemented jsSHA library installed using npm. When I initiate the object getting Uncaught TypeError: jsSHA is not a constructor. Below my code

const hash_obj_mobile_number = new jsSHA("SHA-256", "TEXT", { encoding: "UTF8" }), hash_obj_consent_pin = new jsSHA("SHA-256", "TEXT", { encoding: "UTF8" }); hash_obj_mobile_number.update(mobile_number); hash_obj_consent_pin.update(login_pin); const hash_mobile_number = hash_obj_mobile_number.getHash("HEX"); const hash_consent_pin = hash_obj_consent_pin.getHash("HEX");

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:24 (13 by maintainers)

github_iconTop GitHub Comments

5reactions
Caligatiocommented, Jan 13, 2021

@joadr: Try adding "esModuleInterop": true into your tsconfig.json if it’s not already in there (see my tsconfig.json for an example). I remember some funniness with TypeScript and default imports which I believe was fixed with that config.

0reactions
sukrut-gscommented, Jul 29, 2021
import * as SHA from "jssha";
const sha = new SHA.default("SHA-256", "TEXT");

This worked for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

jssha - npm
Instantiate a new jsSHA object with the desired hash variant, input format, and options as parameters. The hash variant can be one of...
Read more >
Microsoft JScript runtime error Object doesn't support this ...
It is occuring when trying to call hmacObj.getHMAC. This is from the jsSHA website: http://jssha.sourceforge.net/ to use the hmac-sha1 algorithm ...
Read more >
jsSHA - SHA Hashes and HMAC in JavaScript
Javascript Course · 1. Instantiate a new jsSHA object (here sha_ob), using new jsSHA() with the desired hash type ('SHA-Type'), and input type...
Read more >
JavaScript Error Objects - Flavio Copes
A SyntaxError is raised when a syntax error is found in a program. Here are some examples of code that generate a syntax...
Read more >
Caligatio/jsSHA | Build 87 | src/common.ts | Coveralls - Test ...
throw new Error("Invalid outputUpper formatting option"); ... Parses an external constructor object and returns a packed number, if possible.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found