返回 首页

支付宝签名配置验证


公私钥生成: https://docs.open.alipay.com/291/106130

进入ssh后

OpenSSL> genrsa -out app_private_key.pem   2048  #生成私钥
OpenSSL> pkcs8 -topk8 -inform PEM -in app_private_key.pem -outform PEM -nocrypt -out app_private_key_pkcs8.pem #Java开发者需要将私钥转换成PKCS8格式
OpenSSL> rsa -in app_private_key.pem -pubout -out app_public_key.pem #生成公钥
OpenSSL> exit #退出OpenSSL程序

配置后验证公钥

 app_private_key = open('/home/wukt/project/python_planet/pem/app_private_key.pem', 'r')
  # 开始计算签名
  key = RSA.importKey(app_private_key.read())
  signer = PKCS1_v1_5.new(key)
  signature = signer.sign(SHA.new("a=123".encode()))
  sign = encodebytes(signature).decode("utf8").replace("\n", "")
  print(sign)
app_private_key = open('/home/wukt/project/python_planet/pem/app_private_key.pem', 'r')
    # 开始计算签名
    key = RSA.importKey(app_private_key.read())
    signer = PKCS1_v1_5.new(key)
     signature = signer.sign(SHA256.new("a=123".encode()))
    sign = encodebytes(signature).decode("utf8").replace("\n", "")
    print(sign)


评论(0)

登录