def preprocess(self, x): if self.type == "file": return processing_utils.decode_base64_to_file(x) elif self.type == "bytes": return processing_utils.decode_base64_to_binary(x) else: raise ValueError("Unknown type: " + self.type + ". Please choose from: 'file', 'bytes'.")
def preprocess(self, x): name, data, is_local_example = x["name"], x["data"], x["is_local_example"] if self.type == "file": if is_local_example: return open(name) else: return processing_utils.decode_base64_to_file(data) elif self.type == "bytes": if is_local_example: with open(name, "rb") as file_data: return file_data.read() return processing_utils.decode_base64_to_binary(data) else: raise ValueError("Unknown type: " + str(self.type) + ". Please choose from: 'file', 'bytes'.")
def test_same_pass(self): key = encryptor.get_key("test") data, _ = processing_utils.decode_base64_to_binary(BASE64_IMAGE) encrypted_data = encryptor.encrypt(key, data) decrypted_data = encryptor.decrypt(key, encrypted_data) self.assertEqual(data, decrypted_data)