from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives.serialization import load_pem_key
def getsign(t,k):
private_key = load_pem_key(k.encode(),password=None,backend=default_backend())
signature = private_key.sign(t.encode(),ec.ECDSA(hashes.SHA256()))
back = base64.b64encode(signature).decode('utf-8')
return back
t = "1731684612" //就是10位时间
k = "-----BEGIN PRIVATE KEY-----\r\nMIGHAgEAMBMGByqUIM" //密钥
getsign("1731684612",k)