Merge branch 'feature/CHINARPA-5092' into feature/uat-tmp
Showing
1 changed file
with
9 additions
and
3 deletions
... | @@ -6,9 +6,15 @@ def aes_encrypt_cbc(data, key, iv): | ... | @@ -6,9 +6,15 @@ def aes_encrypt_cbc(data, key, iv): |
6 | return cipher.encrypt(data) | 6 | return cipher.encrypt(data) |
7 | 7 | ||
8 | def aes_decrypt_cbc(data, key, iv): | 8 | def aes_decrypt_cbc(data, key, iv): |
9 | cipher = AES.new(key.encode(), AES.MODE_CBC, iv.encode()) | 9 | res = '' |
10 | res = cipher.decrypt(b64decode(data)) | 10 | try: |
11 | return res.decode('utf-8') | 11 | cipher = AES.new(key.encode(), AES.MODE_CBC, iv.encode()) |
12 | res = cipher.decrypt(b64decode(data)) | ||
13 | res = res.decode('utf-8') | ||
14 | except Exception as e: | ||
15 | res = '' | ||
16 | return res | ||
17 | |||
12 | 18 | ||
13 | # 示例使用 | 19 | # 示例使用 |
14 | key = 'm0XsOHC52YZ5KtakhpuMSZtF7DhwudmG' # 密钥长度必须是16、24或32字节 | 20 | key = 'm0XsOHC52YZ5KtakhpuMSZtF7DhwudmG' # 密钥长度必须是16、24或32字节 | ... | ... |
-
Please register or sign in to post a comment