title: Google Apps Script - Making a url request using sha1 and base64 encode
body: <p>I have to make a url request with Google Apps Script and for that, I need to enncode my login and password using a sha 1 algorithm and a base64 encoding. In the documantation for the request, I have the following php code :</p>
  
  <p><code>$string = "loginpassword2017-15-04T09:25:00";
     $hash = sha1($string, true);
     $hash = base64_encode($hash);</code></p>
  
  <p>So in Google Apps Script, i use the following code :</p>
  
  <p><code>function GetSHA1(input) {
       var rawHash = Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_1, input);
       var txtHash = '';
       for (j = 0; j &lt;rawHash.length; j++) {
         var hashVal = rawHash[j];
         if (hashVal &lt; 0)
           hashVal += 256; 
         if (hashVal.toString(16).length == 1)
          txtHash += "0";
         txtHash += hashVal.toString(16);
         }
       return txtHash;
     }</code></p>
  
  <p>and then the function </p>
  
  <p><code>Utilities.base64Encode</code></p>
  
  <p>Finally I make the url request but authentication is unsuccessful. Does someone know how to do a php sha1 and base64encode in Google Apps Script ? Thanks</p>