Tuesday 6 June 2017

Why utf8 encoding of the string gives the string that is unchanged in return

My code is as shown below:

let createCipher = (req, res) => {
    const text = req.body.text;
    let hash = crypto.createHash('md5').update(utf8.encode(text)).digest('hex');
    res.json({
        status: '200',
        data: hash,
        utf: utf8.encode(text)
    });
}

Here, whatever I give as text input parameter, the same will be return in the response field utf. so is there anything missing from utf8 process?



via M thaker

No comments:

Post a Comment