MCPcopy Create free account
hub / github.com/doraemonext/wechat-python-sdk / encode

Method encode

wechat_sdk/lib/crypto/pkcs7.py:11–24  ·  view source on GitHub ↗

对需要加密的明文进行填充补位 @param text: 需要进行填充补位操作的明文 @return: 补齐明文字符串

(cls, text)

Source from the content-addressed store, hash-verified

9
10 @classmethod
11 def encode(cls, text):
12 """
13 对需要加密的明文进行填充补位
14 @param text: 需要进行填充补位操作的明文
15 @return: 补齐明文字符串
16 """
17 text_length = len(text)
18 # 计算需要填充的位数
19 amount_to_pad = cls.block_size - (text_length % cls.block_size)
20 if amount_to_pad == 0:
21 amount_to_pad = cls.block_size
22 # 获得补位所用的字符
23 pad = to_binary(chr(amount_to_pad))
24 return text + pad * amount_to_pad
25
26 @classmethod
27 def decode(cls, decrypted):

Callers 6

encryptMethod · 0.95
to_binaryFunction · 0.45
check_signatureMethod · 0.45
parse_dataMethod · 0.45
requestMethod · 0.45

Calls 1

to_binaryFunction · 0.90

Tested by

no test coverage detected