呜呜 被坑了。
`
import base64
from Crypto.Hash import SHA1
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
def get_sign():
private_key = '''
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALt0f8OlkIYt8R3BjGzQ5z+lNAPvdog/f2xshG9dl7b0X+AIs029VQzgsPj1u3tGQMRRkw7RNNdOSW9b4oYVBYyBm6y4CeYdPjt7gihZ2JEf2FFWhFCXdjKRO/mbwinSfbb6rr3RFjSXQ2HfY2D791/o+yAESDDlLlgz8o+qWiD9AgMBAAECgYEAjo3e57tN+CyR884P62TGp4kL0H5YBu87CQpRgJuNV83p52bWbKUyO7PYAcxmQi4/7MwYaKlCZQYdJHmc/9iWuV7bW36BH1Era1bZbrhu343YzEjgy1TENTKUqfSJeBCj3k5a9rceHM/5Hux64oJtG4QcewgWRnaLzjZljm72QwUCQQD3l4om9Y4XDY12VG0180CH5ohjGeu+fIU+193cmgAcPiySVYKGga4OJ6FTrancjlNtvIPEMuE5O81Sj9yM2AIvAkEAwdInmeqRvKGRadiAq/MKKvnidediqrKL4lFOT00p2ZvFy43mvQNM7cjw/ZE9paaQcsJPfKl6HaYDsigACuUgkwJANMfuYJ3KW6m89XPMEEs5/36qpo25DtOWyC3WkxeVXG/4qn1mJOxyQXw7TQ5hfq4spOEiKeo6zyureqVGfBP0awJAXYIIPQegHANO5mPfYBW3OBiqmvtw7K2LMzrKrxOpNyUh/hyNz27CNI4XRh5GQZ7kXZlFQ/13vsoTSmZl7tuwJQJBALMvBOf4zYkOw8PhV/FO1vs95jFDhmNYDPfjoyH3R0DUpMdNB6X3lI4hO1IKfg0jIEPXSX237f1/kwlYSKRr34s=
'''
content = "appId=1018&appVersion=4.24.0812&device=msm8996&deviceId=29ebc07586da77fd4a6c3be73af92143&deviceName=msm8996&imei=nil&lableId=1&lc=05593cc1-8098-4025-950e-fe753d82d06f&loginId=d27ad52a-1fb1-4afd-9005-88f1ebc9f4f5&lp=a27b2eac-84bc-4fde-9b29-7cae7e850369&pageIndex=1&pid=8404&sid=2&signalType=UNKNOWN&sysV"
print(content)
private_key_bytes = base64.b64decode(private_key)
pri_key = RSA.importKey(private_key_bytes)
signer = PKCS1_v1_5.new(pri_key, )
hash_obj = SHA1.new(content.encode('utf-8'))
signature1 = base64.b64encode(signer.sign(hash_obj))
signature = signature1.decode('utf-8')
print(signature)
get_sign()
`
标签:python,base64,sha1withrsa,private,sign,content,如何,key,import From: https://www.cnblogs.com/zhilele/p/18382597