@@ -128,11 +128,10 @@ def encrypt_file(self, file: str, key: int = 0) -> bool:
128128 assert isinstance (file , str ) and isinstance (key , int )
129129
130130 try :
131- with open (file ) as fin :
132- with open ("encrypt.out" , "w+" ) as fout :
133- # actual encrypt-process
134- for line in fin :
135- fout .write (self .encrypt_string (line , key ))
131+ with open (file ) as fin , open ("encrypt.out" , "w+" ) as fout :
132+ # actual encrypt-process
133+ for line in fin :
134+ fout .write (self .encrypt_string (line , key ))
136135
137136 except OSError :
138137 return False
@@ -152,11 +151,10 @@ def decrypt_file(self, file: str, key: int) -> bool:
152151 assert isinstance (file , str ) and isinstance (key , int )
153152
154153 try :
155- with open (file ) as fin :
156- with open ("decrypt.out" , "w+" ) as fout :
157- # actual encrypt-process
158- for line in fin :
159- fout .write (self .decrypt_string (line , key ))
154+ with open (file ) as fin , open ("decrypt.out" , "w+" ) as fout :
155+ # actual encrypt-process
156+ for line in fin :
157+ fout .write (self .decrypt_string (line , key ))
160158
161159 except OSError :
162160 return False
0 commit comments