我在下面阅读了MD5的解决方案,但我无法理解.
从computeDigest(algorithm,value)byte []获取字符串表示
我想用HMAC-SHA256哈希创建API签名.
var date = new Date();
var nonce = Math.floor(date.getTime()/1000);
var url = "https://mysweet.com/api/accounts"
var secret = "my_secret";
var signature = Utilities.computeHmacSha256Signature(nonce+url, secret);
Run Code Online (Sandbox Code Playgroud)
但它返回字节数组[42,-8,-47,-21,..],它不能直接用作API签名.有没有一种从方法中获取Hex值的简单方法?还是转换?
我想在 GAS 中使用 unix 时间戳进行计数。
var nonce = Math.floor((date.getTime()/1000))
Run Code Online (Sandbox Code Playgroud)
是我的第一个想法。但是 GAS 将此变体处理为1.482239855E9- 9th Gig 格式 - 而不是1482239855.
当我将它与其他字符串连接时,它显示1482239855my_string,这很好。
问题是我将此随机数发送到服务器并进行加密1482239855my_string以进行身份验证,然后随机数将与1.482239855E9vs不匹配1482239855。
我怎样才能得到这个随机数作为整数格式?在电子表格中,我知道setNumberFormat("0")的方法range。有没有类似的方法或属性?