title: DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server
body: <p>Getting error when script move to other server. </p>
  
  <blockquote>
    <p>(node:15707) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.  </p>
  </blockquote>
  
  <p>Current Versions:  </p>
  
  <pre><code>Ubuntu 16.04.4 LTS  
  Node - v10.9.0  
  NPM - 6.2.0  
  </code></pre>
  
  <p>Previous Version:</p>
  
  <pre><code>Ubuntu 14.04.3 LTS
  NPM - 3.10.10
  Node - v6.10.3
  </code></pre>
  
  <p><br></p>
  
  <pre><code>exports.basicAuthentication = function (req, res, next) {
      console.log("basicAuthentication");
      if (!req.headers.authorization) {
          return res.status(401).send({
              message: "Unauthorised access"
          });
      }
      var auth = req.headers.authorization;
      var baseAuth = auth.replace("Basic", "");
      baseAuth = baseAuth.trim();
      var userPasswordString = new Buffer(baseAuth, 'base64').toString('ascii');
      var credentials = userPasswordString.split(':');
  
      var username = credentials[0] !== undefined ? credentials[0] : '';
      var password = credentials[1] !== undefined ? credentials[1] : '';
      var userQuery = {mobilenumber: username, otp: password};
      console.log(userQuery);
      User.findOne(userQuery).exec(function (err, userinfo) {
          if (err || !userinfo) {
               return res.status(401).send({
                  message: "Unauthorised access"
               });
          } else {
              req.user = userinfo;
              next();
          }
      });
  
   }
  </code></pre>