Пример #1
0
        public async Task <string> walletExportIpfs(
            string exportKey, string walletKey = "")
        {
            string path = IOFacilitator.homePath() + d_identifier + "WBtemp";

            try
            {
                // create export file
                await walletExportLocal(path, exportKey);

                // convert export file from byte file to txt file
                string textFilePath = IOFacilitator.convertByteToTextFile(
                    d_identifier + "WBtemp");

                // upload text file to ipfs
                IpfsFacilitator ipfs     = new IpfsFacilitator();
                string          ipfsPath = await ipfs.addFile(textFilePath);

                WalletBackupModel model = new WalletBackupModel(
                    ipfsPath,
                    d_identifier,
                    (walletKey == "" ? d_identifier : walletKey),
                    exportKey);

                model.exportToJsonFile();

                return(JsonConvert.SerializeObject(model));
            }
            catch (Exception e)
            {
                return($"Error: {e.Message}");
            }
        }
Пример #2
0
        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());
        }