Crypt or crypt is not defined hybrid-crypto.min.js
DreamUFO opened this issue · comments
I use hybrid-crypto.min.js in local file,open in brower for testing.
when use new Crypt() or new crypt() ,both exception is 'Uncaught TypeError: (C)crypt is not a constructor'.
must use in webpack?
can anyone help?
Hi, I am also experiencing this issue. Any progress?
Same problem here. Any news?
@juhoen
Seems the minified file isn't refreshed? CHanges in lib are newer then the generated hybrid-crypto.min.js file?
Is there an updated / working version available?
Found solution for React (web)
- index.html file:
<head>
<script type="text/javascript" src="hybrid-crypto.min.js"></script>
...
</head>
- somefile.js in React project:
const webKeyPrivate = require('./keys/clientPrivate.json').value;
const serverKeyPublic = require('./keys/serverPublic.json').value;
let entropy = "random string here";
let crypt = new window.crypt({entropy: entropy}); //not new Crypt or window.Crypt
export default class SomeClass {
function name (messageBody) {
let signature = crypt.signature(webKeyPrivate, messageBody);
let encryptedBody = crypt.encrypt(serverKeyPublic, messageBody, signature);
...action with encryptedBody
};
...
}
Maybe someone can recommend how it is safer to store keys in React one-page website project?
I updated library recently and based on my testing with React project, everything works just fine. Also importing:
const { Crypt, RSA } = require('hybrid-crypto-js');