lib/middleware/authentication.js
function calculateSignature(stringToSign, signingKey, algorithm) {
  const signature = createHmac(algorithm, signingKey);
  signature.update(stringToSign, "utf8");
  return signature.digest("base64");
}
function calculateSignature(stringToSign, signingKey, algorithm) {
  const signature = createHmac(algorithm, signingKey);
  signature.update(stringToSign, "utf8");
  return signature.digest("base64");
}
function calculateSignature ( stringToSign , signingKey , algorithm ) { const signature = createHmac ( algorithm , signingKey ) ; signature . update ( stringToSign , "utf8" ) ; return signature . digest ( "base64" ) ; }
Performs the calculation of an authentication code for a string using the specified key and
algorithm.

@param {String} stringToSign the string representation of a canonical request
@param {String} signingKey a secret access key for V2 signing, or a signing key for V4 signing
@param {String} algorithm should be one of "sha1" or "sha256"
Performs the calculation of an authentication code for a string using the specified key and algorithm .