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)
| 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 |
nothing calls this directly
no test coverage detected