public void EncryptDecryptReturnsSameString() { // arrange var encryptor = new DPAPIEncryptor(); var stringToEncrypt = "stringToEncrypt"; // act var encryptedString = encryptor.Encrypt(stringToEncrypt); var decryptedString = encryptor.Decrypt(encryptedString); // assert Assert.AreEqual(stringToEncrypt, decryptedString); }
public async virtual Task <ActionResult> DownloadImageTemplate(string imageTemplatePath) { var encryptor = new DPAPIEncryptor(); var uriString = encryptor.Decrypt(imageTemplatePath); var uri = new Uri(uriString, UriKind.Absolute); var contentDisposition = new ContentDisposition() { FileName = uri.Segments.Last(), Inline = false, }; var webClient = new WebClient(); webClient.UseDefaultCredentials = true; var fileData = await webClient.DownloadDataTaskAsync(uri); Response.AppendHeader("Content-Disposition", contentDisposition.ToString()); return(File(fileData, "image/png")); }