使用key对password明文进行加密
(plain_password, key)
| 34 | |
| 35 | |
| 36 | def encrypt(plain_password, key): |
| 37 | """使用key对password明文进行加密""" |
| 38 | if plain_password is None or plain_password == "": |
| 39 | return plain_password |
| 40 | if key is None: |
| 41 | raise ServerError(errcode.E_SERVER, "Encrypt key should not be none.") |
| 42 | key = __encode(key) |
| 43 | aes = pyaes.AESModeOfOperationCTR(key) |
| 44 | pwd = b2a_hex(aes.encrypt(plain_password)) |
| 45 | return __decode(pwd) |
| 46 | |
| 47 | |
| 48 | def decrypt(cipher_password, key): |
no test coverage detected