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 :
$string = "loginpassword2017-15-04T09:25:00";
$hash = sha1($string, true);
$hash = base64_encode($hash);
So in Google Apps Script, i use the following code :
function GetSHA1(input) {
var rawHash = Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_1, input);
var txtHash = '';
for (j = 0; j <rawHash.length; j++) {
var hashVal = rawHash[j];
if (hashVal < 0)
hashVal += 256;
if (hashVal.toString(16).length == 1)
txtHash += "0";
txtHash += hashVal.toString(16);
}
return txtHash;
}
and then the function
Utilities.base64Encode
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