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: str, key: int)
| 210 | return True |
| 211 | |
| 212 | def decrypt_file(self, file: str, key: int) -> bool: |
| 213 | """ |
| 214 | input: filename (str) and a key (int) |
| 215 | output: returns true if decrypt process was |
| 216 | successful otherwise false |
| 217 | if key not passed the method uses the key by the constructor. |
| 218 | otherwise key = 1 |
| 219 | """ |
| 220 | |
| 221 | # precondition |
| 222 | assert isinstance(file, str) |
| 223 | assert isinstance(key, int) |
| 224 | |
| 225 | # make sure key is an appropriate size |
| 226 | key %= 256 |
| 227 | |
| 228 | try: |
| 229 | with open(file) as fin, open("decrypt.out", "w+") as fout: |
| 230 | # actual encrypt-process |
| 231 | for line in fin: |
| 232 | fout.write(self.decrypt_string(line, key)) |
| 233 | |
| 234 | except OSError: |
| 235 | return False |
| 236 | |
| 237 | return True |
| 238 | |
| 239 | |
| 240 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected