public async Task <string> downloadEmergencyEHR() { IpfsFacilitator ipfs = new IpfsFacilitator(); string encryptedEHR = await ipfs.getFile(ipfs_path, ""); // decrypt ehr data CipherFacilitator cipher = new CipherFacilitator(); cipher.setKey(encryption_key); cipher.setIV(encryption_iv); return(cipher.decrypt(encryptedEHR)); }
static public async Task <string> backupEHR(string walletId, string ehrJson) { // encrypt ehr data CipherFacilitator cipher = new CipherFacilitator(); string encryptedEHR = cipher.encrypt(ehrJson); string relPath = walletId + "ESjson.temp"; IOFacilitator.createFile(encryptedEHR, relPath); IpfsFacilitator ipfs = new IpfsFacilitator(); string localPath = IOFacilitator.homePath() + relPath; string ipfsPath = await ipfs.addFile(localPath); ShellFacilitator.Bash("rm -f " + localPath); EHRBackupModel model = new EHRBackupModel(ipfsPath, cipher.getKey(), cipher.getIV()); model.exportToJsonFile(walletId); return(model.toJson()); }