juhoen / hybrid-crypto-js

RSA+AES hybrid encryption implementation for JavaScript. Works with Node.js, React Native and modern browsers.

Home Page:https://github.com/juhoen/hybrid-crypto-js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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?

commented

@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)

  1. index.html file:
<head>
<script type="text/javascript" src="hybrid-crypto.min.js"></script>
...
</head>
  1. 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');