0

I am including crypto module in node.js, but its methods are not accessible

var crypto = require("crypto");
exports.testSHA = function(req,res) {
    var shasum = crypto.createHash('sha1');
}

on createHash it says Unresolved function or method createHash().

Is there anything to include a module?

gevorg
  • 4,273
  • 4
  • 32
  • 49
JN_newbie
  • 2,760
  • 8
  • 45
  • 79
  • What does `crypto` contain post the `require` call? – Noam Rathaus Dec 23 '13 at 12:29
  • yes it will post the call, but why I cannot see a method createHash() method? – JN_newbie Dec 23 '13 at 12:34
  • That should work, crypto is built in to Node, and it has a createHash function, and even the variable names are right out of the manual, so something else must be wrong. – adeneo Dec 23 '13 at 12:37
  • What if you run `node -v` in your console. What is the output. – Krasimir Dec 23 '13 at 12:44
  • So what does `crypto` contain if you run `console.debug(crypto)`? – Noam Rathaus Dec 23 '13 at 12:48
  • console.debug in the code? if i write this line in the code it throws an exception TypeError: Object # has no method 'debug' – JN_newbie Dec 23 '13 at 12:51
  • `console.debug` is not available in node.js "yet", your code snippet looks simple, and i don't see anything wrong with it. i executed this, and it didn't throw any errors, crypto, is in standard node.js installation. Try to open up, a simple node.js shell, and write `console.log(require('crypto').getHashes())` it should output a list of all available hashes , if not, then there is a problem somewhere else.. – Gntem Dec 23 '13 at 21:07

0 Answers0