Skip to content

Commit

Permalink
fix: sha1算法替换成sha256 TencentBlueKing#1464
Browse files Browse the repository at this point in the history
  • Loading branch information
huangpixu committed Jan 3, 2025
1 parent 8931e5a commit e2e2014
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions blueking/component/open/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,18 @@


def get_signature(method, path, app_secret, params=None, data=None):
"""generate signature
"""
"""generate signature"""
kwargs = {}
if params:
kwargs.update(params)
if data:
data = json.dumps(data) if isinstance(data, dict) else data
kwargs['data'] = data
kwargs = '&'.join([
'%s=%s' % (k, v)
for k, v in sorted(iter(kwargs.items()), key=lambda x: x[0])
])
orignal = '%s%s?%s' % (method, path, kwargs)
kwargs["data"] = data
kwargs = "&".join(
["%s=%s" % (k, v) for k, v in sorted(iter(kwargs.items()), key=lambda x: x[0])]
)
orignal = "%s%s?%s" % (method, path, kwargs)
signature = base64.b64encode(
hmac.new(
str(app_secret),
orignal,
hashlib.sha1).digest())
hmac.new(str(app_secret), orignal, hashlib.sha256).digest()
)
return signature

0 comments on commit e2e2014

Please sign in to comment.