首页 > 编程语言 > 详细

使用Python 计算KS3 签名,

时间:2020-12-12 23:31:12      阅读:46      评论:0      收藏:0      [点我收藏+]

1. 通过 HTTP 请求 Header 发送的签名

算法

Signature = base64(hmac - sha1(VERB + "\n"
                               + CONTENT - MD5 + "\n"
                               + CONTENT - TYPE + "\n"
                               + DATE + "\n"
                               [+ CanonicalizedKssHeaders + "\n"]
                               + CanonicalizedResource, SecreteKey))

示例:

import hashlib
import hmac
import base64

verb = ‘PUT‘
md5 = ‘xxxxx‘
content_type = ‘xxx‘
date = ‘xxxxx‘
resource = ‘/xxx‘

string_to_sgin = verb +‘\n‘ + md5 + ‘\n‘ + content_type + ‘\n‘ + date_ + ‘\n‘  + resource

sginature = base64.encodebytes(hmac.new(sk.encode(),string_to_sgin.encode(),hashlib.sha1).digest()).strip().decode()

2. 通过URL QueryString发送的签名

算法

Signature = base64(hmac - sha1(VERB + "\n"
+ "" + "\n"
+ "" + "\n"
+ Expires + "\n"
+ CanonicalizedResource, SecreteKey))
示例:
import hashlib
import hmac
import base64

string_to_sgin2 =  ‘GET‘ + ‘\n‘ + ‘\n‘ + ‘\n‘ + ‘1607782768‘ + ‘\n‘ + ‘/‘

sginature = base64.encodebytes(hmac.new(sk.encode(),string_to_sgin2.encode(),hashlib.sha1).digest()).strip().decode()

 

使用Python 计算KS3 签名,

原文:https://www.cnblogs.com/zhangmingda/p/14127215.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!