MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / decrypt_file

Method decrypt_file

ciphers/xor_cipher.py:158–181  ·  view source on GitHub ↗

input: filename (str) and a key (int) output: returns true if decrypt process was successful otherwise false if key not passed the method uses the key by the constructor. otherwise key = 1

(self,file, key)

Source from the content-addressed store, hash-verified

156
157
158 def decrypt_file(self,file, key):
159 """
160 input: filename (str) and a key (int)
161 output: returns true if decrypt process was
162 successful otherwise false
163 if key not passed the method uses the key by the constructor.
164 otherwise key = 1
165 """
166
167 #precondition
168 assert (isinstance(file,str) and isinstance(key,int))
169
170 try:
171 with open(file,"r") as fin:
172 with open("decrypt.out","w+") as fout:
173
174 # actual encrypt-process
175 for line in fin:
176 fout.write(self.decrypt_string(line,key))
177
178 except:
179 return False
180
181 return True
182
183
184

Callers

nothing calls this directly

Calls 1

decrypt_stringMethod · 0.95

Tested by

no test coverage detected