Hmac算法:Keyed-Hashing for Message Authentication。它通过一个标准算法,在计算哈希的过程中,把key混入计算过程中。

import time
from hashlib import sha1
import hmac
import base64

username="xxxx"
apiKey="yyyy"
date=time.strftime("%a, %d %b %Y %H:%M:%S GMT",time.localtime())
my_sign = hmac.new(apiKey,date,sha1).digest()
password = base64.b64encode(my_sign)
print password

 

shell:

 

#!/bin/bash

username="XXXX"

apiKey="YYYY"

date=`env LANG="en_US.UTF-8" date -u "+%a, %d %b %Y %H:%M:%S GMT"`

password=`echo -en "$date" | openssl dgst -sha1 -hmac $apiKey -binary | openssl enc -base64`

相关文章:

  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
  • 2021-10-08
  • 2022-02-11
  • 2022-01-30
  • 2021-06-19
猜你喜欢
  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
  • 2021-05-08
  • 2022-12-23
  • 2021-07-19
  • 2022-12-23
相关资源
相似解决方案