title: Can't convert image buffer to base64 string
body: <p>In my server, I am receiving a POST request for multipart form data in which I receive a PNG image file. I used Buffer.slice() to get the original PNG image. But while experimenting with the formatted Buffer I found that:</p>
  
  <pre><code>console.log(requestBody.compare(Buffer.from(requestBody.toString('base64'))));
  </code></pre>
  
  <p>This statement returns -1. ( Here requestBody is the formatter image buffer )<br>
  My doubt is shouldn't this statement return 0 because I am converting the same buffer to string and then back to buffer ?</p>
  
  <p>My code: </p>
  
  <pre><code>const http = require('http');
  const fs = require('fs');
  const qs = require('querystring');
  const path = require('path');
  
  http.createServer(function ( request, response ) {
  
    if ( request.method == 'GET' ) {
      fs.readFile('./views/index.html', function ( error, data ) {
        response.writeHead(200, {'Content-Type':'text/html'});
        response.end(data);
      });
    } else if ( request.method == 'POST' ) {
      let requestBody = null;
      request.on('data', function( data ) {
        if ( requestBody == null ) {
          requestBody = data;
        } else {
          requestBody += data;
        }
      });
      request.on('end', function( data) {
        requestBody = Buffer.from(requestBody.slice(requestBody.indexOf('image/png') + 13, requestBody.lastIndexOf('------')-1));
        console.log(requestBody.compare(Buffer.from(requestBody.toString('base64'))));
        response.writeHead(200, {'Content-Type':'image/png'});
        response.end(requestBody);
      });
    }
  
  }).listen(3000);
  </code></pre>