/// <summary> /// Gets the encrypted query string. /// </summary> /// <param name="imageUri">The image URI.</param> /// <returns></returns> public static string EncryptUri(this Uri imageUri) { Arg.IsNotNull(() => imageUri); var encryptor = new DPAPIEncryptor(); return(encryptor.Encrypt(imageUri.ToString())); }
public void EncryptReturnsNotSameString() { // arrange var encryptor = new DPAPIEncryptor(); var stringToEncrypt = "stringToEncrypt"; // act var encryptedString = encryptor.Encrypt(stringToEncrypt); // assert Assert.AreNotEqual(stringToEncrypt, encryptedString); }
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")); }