标签:
最近在研究云存储。 如果没有相关背景知识的朋友,请先百度。
我首先要说的是是签名算法错误问题,可能是他们网站内容错误,请核查。
如下。
http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-authentication-HTTPPOST.html
样例网站如下:
http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-post-example.html
我采用三方在线加密网站,算出来的密码与AMAZON不一样。
自己写了一个小程序,算出来的与三方是一样。真不明白AMAZON是怎么算的签名?求指导。
源代码如下:
1 String key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"; 2 using (var algorithm = KeyedHashAlgorithm.Create("HMACSHA256")) 3 { 4 algorithm.Key = Encoding.UTF8.GetBytes(key); 5 string data = "eyAiZXhwaXJhdGlvbiI6ICIyMDEzLTA4LTA3VDEyOjAwOjAwLjAwMFoiLA0KICAiY29uZGl0aW9ucyI6IFsNCiAgICB7ImJ1Y2tldCI6ICJleGFtcGxlYnVja2V0In0sDQogICAgWyJzdGFydHMtd2l0aCIsICIka2V5IiwgInVzZXIvdXNlcjEvIl0sDQogICAgeyJhY2wiOiAicHVibGljLXJlYWQifSwNCiAgICB7InN1Y2Nlc3NfYWN0aW9uX3JlZGlyZWN0IjogImh0dHA6Ly9leGFtcGxlYnVja2V0LnMzLmFtYXpvbmF3cy5jb20vc3VjY2Vzc2Z1bF91cGxvYWQuaHRtbCJ9LA0KICAgIFsic3RhcnRzLXdpdGgiLCAiJENvbnRlbnQtVHlwZSIsICJpbWFnZS8iXSwNCiAgICB7IngtYW16LW1ldGEtdXVpZCI6ICIxNDM2NTEyMzY1MTI3NCJ9LA0KICAgIFsic3RhcnRzLXdpdGgiLCAiJHgtYW16LW1ldGEtdGFnIiwgIiJdLA0KDQogICAgeyJ4LWFtei1jcmVkZW50aWFsIjogIkFLSUFJT1NGT0ROTjdFWEFNUExFLzIwMTMwODA2L3VzLWVhc3QtMS9zMy9hd3M0X3JlcXVlc3QifSwNCiAgICB7IngtYW16LWFsZ29yaXRobSI6ICJBV1M0LUhNQUMtU0hBMjU2In0sDQogICAgeyJ4LWFtei1kYXRlIjogIjIwMTMwODA2VDAwMDAwMFoiIH0NCiAgXQ0KfQ=="; 6 byte[] key2 = algorithm.ComputeHash(Encoding.UTF8.GetBytes(data)); 7 string show = BitConverter.ToString(key2).Replace("-", "").ToLowerInvariant(); 8 MessageBox.Show(show); 9 }
标签:
原文地址:http://www.cnblogs.com/xhu218/p/4709540.html