python 模拟 PHP SHA256验签

php 

openssl_verify($data, $this->urlSafeBase64decode($sign), $public_key, OPENSSL_ALGO_SHA256)

from Crypto.Hash import SHA256
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5 as Signature_pkcs1_v1_5
pubKey = RSA.importKey(conf.otherPubKey)
verifier = Signature_pkcs1_v1_5.new(pubKey)
最重要的是这一点 同理这个可以换成其他
digest = SHA256.new()
digest.update(message.encode())
# base64解密之后验签
is_verify = verifier.verify(digest, decode_base64(signature.encode()))

你可能感兴趣的:(python 模拟 PHP SHA256验签)