MCPcopy Create free account
hub / github.com/geekcomputers/Python / decrypt_file

Method decrypt_file

XORcipher/XOR_cipher.py:155–177  ·  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

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

Callers

nothing calls this directly

Calls 1

decrypt_stringMethod · 0.95

Tested by

no test coverage detected