Click here to Skip to main content
15,891,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when I encrypt my file header only getting encrypted. what ever the content in my file not getting encrypted.
C#
string uploadedFilePath = @"E:\New Folder\";
FileUpload1.SaveAs(uploadedFilePath + Encrypt(FileUpload1.FileName));

public static string Encrypt(string input)
{
  byte[] inputArray = UTF8Encoding.UTF8.GetBytes(input);
  TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider();
           
  ICryptoTransform cTransform = tripleDES.CreateEncryptor();
  byte[] resultArray = cTransform.TransformFinalBlock(inputArray, 0, inputArray.Length);
  tripleDES.Clear();
  return Convert.ToBase64String(resultArray, 0, resultArray.Length);
}
Posted
Updated 12-Aug-12 19:47pm
v2

1 solution

You are encrypting the filename only FileUpload1.SaveAs(uploadedFilePath + Encrypt(FileUpload1.FileName));. To encrypt the whole file you need to encrypt the file content (not only the name).

Nathan Blomquist have written an article about this:
File Encryption/Decryption with Hash Verification in C#[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900