我正在尝试运行脚本来获取aws签名密钥的十六进制表示。但相反,我在终端上得到了这个:
???>?^?c???w?,????-??e??$C
我的代码出了什么问题?
#!/usr/bin/env ruby
require 'openssl'
def getSignatureKey key, dateStamp, regionName, serviceName
kDate = OpenSSL::HMAC.digest('sha256', "AWS4" + key, dateStamp)
kRegion = OpenSSL::HMAC.digest('sha256', kDate, regionName)
kService = OpenSSL::HMAC.digest('sha256', kRegion, serviceName)
kSigning = OpenSSL::HMAC.digest('sha256', kService, "aws4_request")
kSigning
end
puts getSignatureKey('wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY','20170110', 'us-west-1', 's3')