hash - 如何为http请求计算亚马逊的MD5哈希值

标签 hash coldfusion amazon-web-services coldfusion-9

有谁知道如何计算与 Amazon 的 SubmitFeed API 一起使用所需的 MD5 哈希值?我使用的是 ColdFusion,每次我计算 MD5 哈希值时,它都与 Amazon 的计算结果不匹配。

亚马逊响应此错误:

ContentMD5DoesNotMatch

the Content-MD5 HTTP header you passed for your feed (C7EF1CADB27497B46FCD6F69516F96E0) did not match the Content-MD5 we calculated for your feed (x+8crbJ0l7RvzW9pUW+W4A==)

我正在使用 ColdFusion 用于散列的内置函数(示例 hash(myStr))。有没有我遗漏的步骤?

最佳答案

public any function EncryptSignature(required string argValue,required string publicKey) hint="I create my own signature that I will matching later." {
    local.filters=StructNew();
    local.filters["F:publicKey"]=arguments.publicKey;
    var jMsg=JavaCast("string",arguments.argValue).getBytes("iso-8859-1");
    var thisSecretKey = getDAO().getSecretKey(local.filters).apiSecretKey;
    var jKey=JavaCast("string",thisSecretKey).getBytes("iso-8859-1");
    var key=createObject("java","javax.crypto.spec.SecretKeySpec");
    var mac=createObject("java","javax.crypto.Mac");
    key=key.init(jKey,"HmacSHA1");
    mac=mac.getInstance(key.getAlgorithm());
    mac.init(key);
    mac.update(jMsg);
    return lCase(binaryEncode(mac.doFinal(),'Hex'));
    //return Encrypt(arguments.argValue,getapiUsersDAO().getSecretKey(arguments.publicKey),'HMAC-SHA1');
    }

关于hash - 如何为http请求计算亚马逊的MD5哈希值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14327201/

相关文章:

ruby - 单个 ruby​​ 进程中的数字上的 `hash` 是否一致?

arrays - 如何从我的散列中删除一个 nil 键?

ajax - Colfdfusion循环状态更新Ajax

email - cfmail 中最多可以包含多少个电子邮件地址

amazon-web-services - AWS secret 管理器, 'A previous rotation isn’ t complete' 轮换 secret 时

amazon-web-services - AWS Cloudformation 包不会更新代码

php - PHP 中的密码哈希 : Am I Doing This Right?

hash - 根据文件内容计算出的MD5哈希值的前4个字节发生冲突的可能性是多少?

java - 从ColdFusion 11 CFZIP创建的Zip文件上的ColdFusion 9 CFZIP解压缩错误

Android Retrofit RestAdapter 在断开连接时获得失败状态