zhuhao commited on
Commit
7cd12e2
·
1 Parent(s): b403f7a

modify the encryption to first perform base64 encoding and then encrypt (#1621)

Browse files

### What problem does this PR solve?

The encryption should first perform base64 encoding and then encrypt, to
maintain consistency with the frontend

#1620

### Type of change

- [x] Refactoring

Files changed (1) hide show
  1. api/utils/t_crypt.py +4 -3
api/utils/t_crypt.py CHANGED
@@ -11,10 +11,11 @@ def crypt(line):
11
  file_utils.get_project_base_directory(),
12
  "conf",
13
  "public.pem")
14
- rsa_key = RSA.importKey(open(file_path).read())
15
  cipher = Cipher_pkcs1_v1_5.new(rsa_key)
16
- return base64.b64encode(cipher.encrypt(
17
- line.encode('utf-8'))).decode("utf-8")
 
18
 
19
 
20
  if __name__ == "__main__":
 
11
  file_utils.get_project_base_directory(),
12
  "conf",
13
  "public.pem")
14
+ rsa_key = RSA.importKey(open(file_path).read(),"Welcome")
15
  cipher = Cipher_pkcs1_v1_5.new(rsa_key)
16
+ password_base64 = base64.b64encode(line.encode('utf-8')).decode("utf-8")
17
+ encrypted_password = cipher.encrypt(password_base64.encode())
18
+ return base64.b64encode(encrypted_password).decode('utf-8')
19
 
20
 
21
  if __name__ == "__main__":