Code Monkey home page Code Monkey logo

dingtalk-python's Issues

ImportError: cannot import name 'JSONDecodeError'

放在web.py 里面,运行时出现异常 ImportError: cannot import name 'JSONDecodeError'
请问这是什么问题呢?

File "E:\HardPython\projects\DingAppServer\webapi.py", line 118, in GET
from dingtalk import DingTalkApp
File "E:\HardPython\projects\DingAppServer\dingtalk_init_.py", line 13, in
from .message import Message
File "E:\HardPython\projects\DingAppServer\dingtalk\message_init_.py", line 8, in
from .conversation import *
File "E:\HardPython\projects\DingAppServer\dingtalk\message\conversation.py", line 11, in
from json import JSONDecodeError
ImportError: cannot import name 'JSONDecodeError'

特定的ciphertext和aes_key会导致解密失败

aes_key: ZC5MWOE8inNkJRbUw3ay9OXl27bnd0SLqXTwfAIqgir
ciphertext: JVjyp8Sgojp6I1oLHA96uc8i/sXsvpmvyVjkxh6jwbP20m2IeoJCkAt/60k80IrqhiPi2ZEobPL+VZa14lj0mw==

调用crypto.py里的decrypt会出错:
File "。。。。/callback/crypto.py", line 111, in
ciphertext='JVjyp8Sgojp6I1oLHA96uc8i/sXsvpmvyVjkxh6jwbP20m2IeoJCkAt/60k80IrqhiPi2ZEobPL+VZa14lj0mw=='))
File "。。。/callback/crypto.py", line 85, in decrypt
length = struct.unpack('!i', raw[16:20])[0]
struct.error: unpack requires a buffer of 4 bytes

调试了一下,发现应该是pkcs7_unpad把信息搞丢了:
pkcs7_unpad之前信息为:
b'AfkpTLMLSlYN7Iuz\x00\x00\x00\x0cheollo worldding02323e3f1d13ae10\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c'

之后为:
AfkpTLMLSlYN7Iuz\x00\x00\x00

注意到\x0c第一次出现在msg前,即位置19处,所以pkcs7_unpad把后面的消息都截取掉了。

我没有研究过具体加密和解密的算法,我这边为了保证信息不会被截取,把pkcs7_unpad方法改了一下:

return text[: text.index(text[-1], 20)]

有懂算法的可以看看这样是否合适。

file 这个模块的操作

file 这个模块,你是说主要针对于钉盘,
能再多介绍一下,我想要实现一个自动下载的功能。

钉钉回调失败失败 返回文本非success

1、env
python 3.5.2

2、现象
回调接口返回数据:
{"msg_signature": "f2b351fe2f0635b80b2f4c8b4bac2b34ff6c294c", "nonce": "12345", "timeStamp": "1551773340805", "encrypt": "h4FvNBrDtsJf8FoOjWB/v9OcpwFtXqFfVLVmfCb/nVer50qXdjFnwOVflT9+rUSp11a+hcyW7zI49IjfgMVEFA=="}

返回结果

{'errcode': 71009, 'errmsg': '返回文本非success'}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.