1010
1111from pyencrypt import __description__ , __version__
1212from pyencrypt .decrypt import decrypt_file
13- from pyencrypt .encrypt import (can_encrypt , encrypt_file , encrypt_key ,
14- generate_so_file )
13+ from pyencrypt .encrypt import (can_encrypt , encrypt_file , encrypt_key , generate_so_file )
1514from pyencrypt .generate import generate_aes_key
1615from pyencrypt .license import MAX_DATETIME , MIN_DATETIME , generate_license_file
1716
3433"""
3534
3635PYTHON_MAJOR , PYTHON_MINOR = sys .version_info [:2 ]
37- LAODER_FILE_NAME = click .style (
38- "encrypted/loader.cpython-{major}{minor}{abi}-{platform}.so" .format (
39- major = PYTHON_MAJOR , minor = PYTHON_MINOR , abi = sys .abiflags , platform = sys .platform
40- ),
41- blink = True ,
42- fg = 'blue'
43- )
36+ LOADER_FILE_NAME = click .style ("encrypted/{}" , blink = True , fg = 'blue' )
4437LICENSE_FILE_NAME = click .style ("license.lic" , blink = True , fg = 'blue' )
4538
4639SUCCESS_ANSI = click .style ('successfully' , fg = 'green' )
5548
5649FINISH_ENCRYPT_MSG = f"""
5750Encryption completed { SUCCESS_ANSI } .
58- Please copy { LAODER_FILE_NAME } into your encrypted directory.
51+ Please copy { LOADER_FILE_NAME } into your encrypted directory.
5952And then remove `encrypted` directory.
6053Finally, add `import loader` at the top of your entry file.\
6154 """
6255
6356FINISH_DECRYPT_MSG = f"""
64- Decryption completed { SUCCESS_ANSI } . Your origin source code has be put: %s
57+ Decryption completed { SUCCESS_ANSI } . Your origin source code has be put: {{work_dir}}
6558"""
6659
6760FINISH_GENERATE_LOADER_MSG = f"""
68- Generate loader file { SUCCESS_ANSI } . Your loader file is located in { LAODER_FILE_NAME }
61+ Generate loader file { SUCCESS_ANSI } . Your loader file is located in { LOADER_FILE_NAME }
6962"""
7063
7164FINISH_GENERATE_LICENSE_MSG = f"""
@@ -187,11 +180,11 @@ def encrypt_command(ctx, pathname, replace, key, with_license, mac, ipv4, before
187180 raise Exception (f'{ path } is not a valid path.' )
188181
189182 cipher_key , d , n = encrypt_key (key .encode ()) # 需要放进导入器中
190- generate_so_file (cipher_key , d , n , license = with_license )
183+ loader_extension = generate_so_file (cipher_key , d , n , license = with_license )
191184 if with_license is True :
192185 generate_license_file (key , Path (os .getcwd ()), after , before , mac , ipv4 )
193186 click .echo (FINISH_GENERATE_LICENSE_MSG )
194- click .echo (FINISH_ENCRYPT_MSG )
187+ click .echo (FINISH_ENCRYPT_MSG . format ( loader_extension . name ) )
195188
196189
197190@cli .command (name = 'decrypt' )
@@ -227,7 +220,7 @@ def decrypt_command(ctx, pathname, replace, key):
227220 else :
228221 raise Exception (f'{ path } is not a valid path.' )
229222
230- click .echo (FINISH_DECRYPT_MSG % work_dir )
223+ click .echo (FINISH_DECRYPT_MSG . format ( work_dir = work_dir ) )
231224
232225
233226@cli .command (name = 'generate' )
@@ -237,8 +230,8 @@ def decrypt_command(ctx, pathname, replace, key):
237230def generate_loader (ctx , key ):
238231 """Generate loader file using specified key"""
239232 cipher_key , d , n = encrypt_key (key .encode ())
240- generate_so_file (cipher_key , d , n , Path (os .getcwd ()))
241- click .echo (FINISH_GENERATE_LOADER_MSG )
233+ loader_extension = generate_so_file (cipher_key , d , n , Path (os .getcwd ()))
234+ click .echo (FINISH_GENERATE_LOADER_MSG . format ( loader_extension . name ) )
242235
243236
244237@cli .command (name = 'license' )
0 commit comments