V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
song135711
V2EX  ›  问与答

有没有做过某书 三方保税订单生成推送 接口的同学, 求一份代码

  •  
  •   song135711 · 2020-06-10 13:19:19 +08:00 · 776 次点击
    这是一个创建于 1660 天前的主题,其中的信息可能已经有所发展或是发生改变。

    对接了好几个电商平台, 只见到这一个奇葩. 保税模式的订单使用推送的方式, 平台自己不做数据的备份工作?! 推送的订单数据进行了加密, 对接的开发, 给了一段 demo 后, 带入参数有错后, 人就没信儿了... 有对接过的同学吗, 求一下解密用的算法和 demo

    1 条回复    2020-07-29 13:18:27 +08:00
    song135711
        1
    song135711  
    OP
       2020-07-29 13:18:27 +08:00
    这里是调试用的代码

    import base64
    import hashlib

    from Crypto.Cipher import PKCS1_v1_5
    from Crypto.PublicKey import RSA

    def red_decrypt():
    ciphertext = "i8e96i0wyA3e0J1etuXR/dkDmKvFRlBuIpdSyzcv18VSq2zp2XjW31tOA/FzdcNi/WHJQT9NAPJe6CDQrFylvDx3Z4vhEHMZOzrv88BW6Dk0dc94j+hsRldBBKnMIXaZRDB9Maj1wTu9TTgvb9D+cEonQnDz3qAQHfzbY0Jz0p5WNfiDE3zi17xQeDVQFe0r1N93jRRfLhEZ35pQFImYKAEFopOQBVEpRxbBhFAjPg1V9DEuEwst42rqmjTgX7Xpt6DuazKwy0zCAucA/FcQVfDr9CkwE5pfPO+RQP2Ku2cbd6iB9yqz0GdO60/Z6ljbvNTE7Npbi67QK0CRcs4x2xgqg+D8mfpkc9bnVz++oiW9I2lkH7P71yCNbNwDBkHMqd08juCkyg06a112MAcwwpHdyQdLdSGGx7XfrFOKmg7ZmQG161PE3FiX2t6sLDSTcmyQlwoQvbiYmsV8Qiho4kc1T4R5xMzaivDOsm6dJ/03+tehXDI+UBxh0MznUwU5Aa/WnnaMkBJ7eK4wePVeHXGazBKGbepnr61zQ0ZdBr1yE78dzuLqG2zkowhMsEvaaiU6n7KSPufkWsvCmn9L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ao6lUWHrrEYXLMpUUU4C8OOA=" # noqa: #501
    pem = "-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQCqblHfz/2ohTf+QendtBqsTVR4m9iNFr4gkVryMGo5AOGkfzkFLGxbza0+PuI9MDZoMQLsSeijryq4iJ2csEIboshudSUyQ4DvXhamDvR8R6kMCZXFFHvD01JtKyUrlFnIRTMdG7sFEN8XF4Vt9FpqOONMb2GyWc9ieosNfoDBEwIDAQABAoGADHpVPjvd7qRwrAneLUabAu09qplM0Ok1J4p2crx+tAiCr+asoXQi+Gzl95ezb31qWyIZ4uJ3L0mLQpI/nKtlVSTcED0GEan+GhhsdMdB8OojSYdXWk3o/L1PpT6rBZa95Y2tZ64UP9axXyIt0YzNw5SCSpySb0qp6L4EaaUEvyECQQDQfhxDaYEkIrf3+YtZEoaKkyAdqfhGUbXPWuRstRa3BswB2RvMoxkRs74XGIkF+aTHprDfeevAJ+PRb+g8UKixAkEA0UP6Ozay28rhvR0+Me74DMjlqsL7dv2ek5LWYKvNXMJnR9XiF7+a6daOn9kDZQ0VAnXyBe5gpbvCD3jfloz3AwJANk4CspRSbMUWQeKfpw2qOYHkxZU186rovh+gi6gHSJjenkScdwqsRu4YPw/G8OV7Q/1o6GxrOVuqfSy2wq8HoQJALRiUFSydcKYQ7Xseyw3vYHnunFT2cdcH1E+BaUW8tK+kKCPcXDfLP3cgNyxCAgXGsEgQhtyu8Sg8Eq9+p2frVwJBAJyXutx7yplpLE/aozG2go20xePmZRTDDi5yPJLGMcBwTamKeVVNWoy/P9sXHs8xK+ChpK+80ku+akYWDMc0WQ4=\n-----END RSA PRIVATE KEY-----" # noqa: #501
    msg = base64.b64decode(ciphertext.encode('utf-8'))
    res = []
    cipher = PKCS1_v1_5.new(RSA.importKey(pem))
    length = 128
    for i in range(0, len(msg), length):
    content = msg[i:i + length]
    ds = cipher.decrypt(content, '')
    res.append(ds)
    res = "".join(res)

    print('解密数据: ', res)
    print('签名后数据: ', "signature")
    return ""


    if __name__ == "__main__":
    red_decrypt()
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1484 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 17:09 · PVG 01:09 · LAX 09:09 · JFK 12:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.