Reputation: 95
Hi All I am very new to the nodejs. I am trying to install the cryptlib module by using the following command for this:
npm install cryptlib
It installing successfully. When I move to myproject ->node_modules
the folder called cryptlib
is there.
But when I include it in my server.js as follow
var CryptLib = require('cryptlib'),
_crypt = new CryptLib(),
plainText = 'This is the text to be encrypted',
iv = _crypt.generateRandomIV(16), //16 bytes = 128 bit
key = _crypt.getHashSha256('my secret key', 32), //32 bytes = 256 bits
cypherText = _crypt.encrypt(plainText, key, iv),
originalText = _crypt.decrypt(cypherText, key, iv);
Then its throwing an error
module.js:340
throw err;
^
Error: Cannot find module 'cryptlib'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/www/html/testing/server.js:9:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
So how can I fix this error? Any help would be appriciated.
Upvotes: 1
Views: 1004
Reputation: 179
Sorry I dont have enough points to reply as a comment before this.
I have updated cryptlib on npm to version 1.0.3 to address this issue. It should work now. Thank you 王庭茂 for your excellent effort.
Also thank you user3446467 for using the module.
If you encounter any further issues please let me know.
Upvotes: 1
Reputation: 2012
It seems to be the problem of the original package. I have sent a pull request to fix this problem. For now, just do what I have done on the pull request and it should work.
Upvotes: 0