public HttpResponseMessage GetAES(string option) { Encryption encryption = new Encryption(); if (option == "encrypt") { encryption.EncryptFile(PathFile, PathFile + "enc", "password"); } else if (option == "decrypt") { encryption.DecryptFile(PathFile + "enc", PathFile, "password"); } HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); var stream = new FileStream(PathFile + "enc", FileMode.Open); result.Content = new StreamContent(stream); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); return result; }
public HttpResponseMessage GetAES(string option, string password) { Encryption encryption = new Encryption(); if (option == "encrypt") { encryption.EncryptFile(PathFile, PathFile + "enc", password); } else if (option == "decrypt") { try { encryption.DecryptFile(PathFile + "enc", PathFile, password); } catch (CryptographicException e) { return new HttpResponseMessage(HttpStatusCode.BadRequest); } } HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); Stream stream; if (option == "encrypt") { stream = new FileStream(PathFile + "enc", FileMode.Open); } else { stream = new FileStream(PathFile, FileMode.Open); } result.Content = new StreamContent(stream); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); return result; }
public void PasswordIsNull_EncryptFile() { Encryption encryption = new Encryption(); encryption.EncryptFile("plik.txt", "encrypted.txt", null); }
public void FilePathIsNull_EncryptFile() { Encryption encryption = new Encryption(); encryption.EncryptFile(null, "encrypted.txt", "password"); }
public void EncryptedFilePathIsNull_EncryptFile() { Encryption encryption = new Encryption(); encryption.EncryptFile("plik.txt", null, "password"); }