private void btnDownload_Click(object sender, EventArgs e) { if (!txtDownloadHash.Text.Equals(String.Empty)) { IpfsWrapper.Get(txtDownloadHash.Text, @"D:\file.docx"); } }
public int ShareFile(string path, string address, string walletAddress) { var plainFile = path; var encrpFile = path + ".enc"; using (RijndaelManaged myRijndael = new RijndaelManaged()) { myRijndael.GenerateKey(); myRijndael.GenerateIV(); // Encrypt the string to an array of bytes. byte[] encrypted = AESExample.AES.EncryptStringToBytes(File.ReadAllText(plainFile), myRijndael.Key, myRijndael.IV); // Decrypt the bytes to a string. //string roundtrip = AESExample.AES.DecryptStringFromBytes(encrypted, myRijndael.Key, myRijndael.IV); File.WriteAllBytes(encrpFile, encrypted); } var hashString = IpfsWrapper.Add(encrpFile).Result; var hashString2 = IpfsWrapper.Add(plainFile).Result; if (hashString != null) { return(1); } return(-1); }
private async void btnUpload_Click(object sender, EventArgs e) { if (System.IO.File.Exists(txtFile.Text)) { string hash = await IpfsWrapper.Add(txtFile.Text); txtHash.Text = hash; txtFile.Text = ""; } }
private void Form1_Load(object sender, EventArgs e) { IpfsWrapper.Init(); if (IpfsWrapper.isDaemonRunning()) { lblStatus.Text = "IPFS Daemon Running..."; lblStatus.ForeColor = Color.Green; } else { lblStatus.Text = "IPFS Daemon Stopped"; lblStatus.ForeColor = Color.Red; } }
static void Main(string[] args) { IpfsWrapper.Init(); string address = "net.pipe://localhost/ShareFileService"; ServiceHost serviceHost = new ServiceHost(typeof(ShareFileService)); NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); serviceHost.AddServiceEndpoint(typeof(IServiceContract), binding, address); serviceHost.Open(); Console.WriteLine("ServiceHost running. Press Return to Exit"); Console.ReadLine(); IpfsWrapper.CloseDaemon(); }