小编Brt*_*rtD的帖子

Google Apps Script - 使用 sha1 和 base64 编码发出 url 请求

我必须使用 Google Apps Script 发出 url 请求,为此,我需要使用 sha 1 算法和 base64 编码对我的登录名和密码进行编码。在请求的文档中,我有以下 php 代码:

$string = "loginpassword2017-15-04T09:25:00"; $hash = sha1($string, true); $hash = base64_encode($hash);

所以在 Google Apps Script 中,我使用以下代码:

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; }

然后函数

Utilities.base64Encode

最后我发出了 url 请求,但身份验证不成功。有人知道如何在 Google …

google-apps-script

0
推荐指数
1
解决办法
1287
查看次数

标签 统计

google-apps-script ×1