1

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.

2 Answers 2

1

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.

0

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.

1
  • @user3446467 Very nice! Lets wait for the pull request to get merged. After the pull request is merged, you may need to re-install the module by removing it and install it again. ( This is probably the easiest way to not case any new problem on version control system. ) And if you can click the little green tick below the downvote bottom ( and / or ) upvote this answer, it will help me to do more on stackoverflow. Thank!
    – maowtm
    Commented Sep 14, 2015 at 14:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.