1: About module crypto;
I am using Crypto.cpmpare (source is below), forgot some second parameter, cause always appear ' data and hash must be strings ',
Looked for a long time, finally by looking at the source code, found that the second parameter did not write;
1 ///Compare raw data to hash2 ///@param {String} data the data to hash and compare3 ///@param {String} hash expected hash4 ///@param {Function} CB callback (err, matched)-matched is true if hashed data matches hash5Module.exports.compare =function(data, hash, CB) {6 if(Data = =NULL|| data = = Undefined | | hash = =NULL|| hash = =undefined) {7 Throw NewError (' data and hash arguments required ');8}Else if(typeofData!== ' String ' | |typeofHash!== ' String ') {9 Throw NewError (' data and hash must be strings ');Ten } One A if(!CB) { - Throw NewError (' Callback required for async compare '); -}Else if(typeofCB!== ' function ') { the Throw NewError (' callback must be a function '); - } - - returnbindings.compare (data, hash, CB); +};View Code
2: About module Body-parser;
Previously this feature was used as a middleware for express, as follows:
App.use (Express.bodyparser ())
Now it is not tied to express and is used directly as a module of node:
var bodyparser = require (' Body-parser ')
If you don't use this, you won't find the data at Req.body.
Nodejs Learning module: Crypto and Body-parser