• 支付宝扫码支付


    应用场景
    二维码收款

    接口
    官方文档:https://doc.open.alipay.com/doc2/apiDetail.htm?spm=a219a.7395905.0.0.O4mxCP&docType=4&apiId=862

    过程
    通过调用接口得到官方的二维码地址,然后再将其展示出来

    问题
    签名&验证略麻烦,官方文档:https://doc.open.alipay.com/doc2/detail.htm?treeId=200&articleId=105351&docType=1
    其中有一个SHA1WithRSA算法(用rsa私钥给数据签名--基于sha1算法),python版本代码如下(需要引用M2Crypto库的EVP类):

    print '-'*100, '
    ', 'sign before:', sign
    private_key = """-----BEGIN RSA PRIVATE KEY-----
    MIICXAIBAAKBgQC/LW6rMzSILfH6reAxdZUdgq/Zo9fyjGnNCXYjGmuzFwEgRNTWAs9x2wK7rrzfTma
    jiJKlvksvcLFCo37Jdzf8nY79789N2e0MAAIwIjgANFUI4nlkA3x7cQv1LPo1b5izNtIzCDyBqhyy07
    xPy2Qu6JQ0i/NZoTHNcZY1p7CZhwIDAQABAoGBAIT9f90Mc+C/xXNS/YCqgR7USKwn9BNAZmFB0bK9s
    GoW+KuP9lciAVj8t7wD5FObYH8mhI1UAU1xIX5v6cUQcBrQ0Gt9Pg5OBzUxFFruVMASpt6Q1k+YuOhk
    YnrQvK2Wab7asV2QCZ5Ac8+l7F/HR237d4BQUZ3OrUnN+mF+wfJxAkEA6ts6+VL0qIchJIJjnjw/MRU
    7wbHf4IO3AngplHVnAKTKv067X4psEDvxQBM8YUZcN7jAsagGnHsJ2ryGlqXf+wUILNBjhyIEi3JB1o
    0UTN2mV+6UaqBukWIBgne/bi9CAV51d7W33h5ULywwYUyGsIr7hZetby9xzKS4bGZG+JvjWuUCQGSAT
    ltVSYc41FD4T0Luiygo6vp3cNN16gHvg/OYzewzmOOHAJ3g8V99Fz8RPDxwTJQ3xpX/zlx2NoBZPssG
    zrMCQHhLfA6fIQBsETaPqW+qPshy1LqYGUTCKlaGI00UhUXJ+bjk00wevLx9kS1j8zXHzG6qp6xzvPa
    5n5nLDmiu7iECQDZPSqqK78xiwvyGD9UjpBUSnPvht9Zwm0FRO4OKtVtnzgSYylms+WS8KpP41Sx51p
    +eA5GoNkGnBK9cOyyVsTY=
    -----END RSA PRIVATE KEY-----"""
    key = EVP.load_key_string(private_key)
    key.reset_context(md='sha1')
    key.sign_init()
    key.sign_update(sign)
    sign = base64.b64encode(key.sign_final())
    sign = quote(sign)
    print '-'*100, '
    ', 'sign after:', sign
  • 相关阅读:
    Android性能优化典范(转)
    java分形树
    android通过pc脚本执行sqlite3脚本
    针对JD-GUI
    三星的中低端机使用AsyncTask的问题
    Github简明教程(转)
    android 5.0 (lollipop)源码编译环境搭建(Mac OS X)
    排队接水
    幂次方
    2020/4/12
  • 原文地址:https://www.cnblogs.com/Tommy-Yu/p/5735521.html
Copyright © 2020-2023  润新知