1919import sys
2020from Cryptodome .PublicKey import RSA
2121from Cryptodome .Cipher import PKCS1_v1_5 as Cipher_pkcs1_v1_5
22- from api . utils import file_utils
22+ from common . file_utils import get_project_base_directory
2323
2424
2525def crypt (line ):
2626 """
2727 decrypt(crypt(input_string)) == base64(input_string), which frontend and admin_client use.
2828 """
29- file_path = os .path .join (file_utils . get_project_base_directory (), "conf" , "public.pem" )
29+ file_path = os .path .join (get_project_base_directory (), "conf" , "public.pem" )
3030 rsa_key = RSA .importKey (open (file_path ).read (), "Welcome" )
3131 cipher = Cipher_pkcs1_v1_5 .new (rsa_key )
3232 password_base64 = base64 .b64encode (line .encode ('utf-8' )).decode ("utf-8" )
@@ -35,7 +35,7 @@ def crypt(line):
3535
3636
3737def decrypt (line ):
38- file_path = os .path .join (file_utils . get_project_base_directory (), "conf" , "private.pem" )
38+ file_path = os .path .join (get_project_base_directory (), "conf" , "private.pem" )
3939 rsa_key = RSA .importKey (open (file_path ).read (), "Welcome" )
4040 cipher = Cipher_pkcs1_v1_5 .new (rsa_key )
4141 return cipher .decrypt (base64 .b64decode (line ), "Fail to decrypt password!" ).decode ('utf-8' )
@@ -50,7 +50,7 @@ def decrypt2(crypt_text):
5050 hex_fixed = '00' + decode_data .hex ()
5151 decode_data = b16decode (hex_fixed .upper ())
5252
53- file_path = os .path .join (file_utils . get_project_base_directory (), "conf" , "private.pem" )
53+ file_path = os .path .join (get_project_base_directory (), "conf" , "private.pem" )
5454 pem = open (file_path ).read ()
5555 rsa_key = RSA .importKey (pem , "Welcome" )
5656 cipher = Cipher_PKCS1_v1_5 .new (rsa_key )
0 commit comments