.版本 2 .子程序 阿里云V4签名, 文本型 .参数 AccessKeyId, 文本型 .参数 AccessKeySecret, 文本型 .参数 examplebucket, 文本型 .参数 exampleobject, 文本型 .参数 RegionId, 文本型 .参数 ServiceName, 文本型 .局部变量 UTC时间, 文本型 .局部变量 日期, 文本型 .局部变量 规范请求, 文本型 .局部变量 待签字符串, 文本型 .局部变量 签名, 文本型 .局部变量 dateKey, 字节集 .局部变量 dateRegionKey, 字节集 .局部变量 dateRegionServiceKey, 字节集 .局部变量 signingKey, 字节集 .局部变量 queryString, 文本型 ' 1. 获取时间戳 UTC时间 = 时间_格式化 (增减时间 (取现行时间 (), #小时, -8), “yyyyMMddT”, “HHmmssZ”, 真, ) 日期 = 取文本左边 (UTC时间, 8) ' 2. 构造规范请求 规范请求 = “GET\n/” + examplebucket + “/” + exampleobject + “\n” 规范请求 = 规范请求 + “x-oss-additional-headers=host&x-oss-credential=” 规范请求 = 规范请求 + AccessKeyId + “%2F” + 日期 规范请求 = 规范请求 + “%2F” + RegionId + “%2Foss%2Faliyun_v4_request&x-oss-date=” + UTC时间 规范请求 = 规范请求 + “host:” + examplebucket + “.” + RegionId + “.aliyuncs.com\n” 规范请求 = 规范请求 + “\n” + “host\n” + “UNSIGNED-PAYLOAD” ' 3. 生成待签字符串 待签字符串 = “OSS4-HMAC-SHA256\n” 待签字符串 = 待签字符串 + UTC时间 + “\n” 待签字符串 = 待签字符串 + 日期 + “/” + RegionId + “/” + ServiceName + “/aliyun_v4_request\n” 待签字符串 = 待签字符串 + 到小写 (校验_取sha256 (到字节集 (规范请求))) ' 4. 计算签名密钥 dateKey = 校验_hmac_sha256_字节集 (到字节集 (“aliyun_v4” + AccessKeySecret), 日期) dateRegionKey = 校验_hmac_sha256_字节集 (dateKey, RegionId) dateRegionServiceKey = 校验_hmac_sha256_字节集 (dateRegionKey, ServiceName) signingKey = 校验_hmac_sha256_字节集 (dateRegionServiceKey, “aliyun_v4_request”) 签名 = 校验_hmac_sha256_十六 (signingKey, 待签字符串) 返回 (签名) |