Nodejs Learning module: Crypto and Body-parser

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.