filename = Path.GetFileName(FileUpload1.PostedFile.FileName); System.IO.Stream myStream; Int32 fileLen; StringBuilder displayString = new StringBuilder(); fileLen = FileUpload1.PostedFile.ContentLength; Byte[] Input = new Byte[fileLen]; // Initialize the stream to read the uploaded file. myStream = FileUpload1.FileContent; // Read the file into the byte array. myStream.Read(Input, 0, fileLen); // Copy the byte array to a string. for (int loop1 = 0; loop1 < fileLen; loop1++) { displayString.Append(Input[loop1].ToString()); } //TextBox1.Text = displayString.ToString(); bytes = ASCIIEncoding.ASCII.GetBytes(dktxt.Text); bytes1 = ASCIIEncoding.ASCII.GetBytes(ck); string originalString = displayString.ToString(); // DES algorithm to encrypt the given file DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider(); MemoryStream memoryStream = new MemoryStream(); CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoProvider.CreateEncryptor(bytes, bytes1), CryptoStreamMode.Write); StreamWriter writer = new StreamWriter(cryptoStream); writer.Write(originalString); writer.Flush(); cryptoStream.FlushFinalBlock(); writer.Flush(); // store the encrypted data of a file cryptedString = Convert.ToBase64String(memoryStream.GetBuffer(), 0, (int)memoryStream.Length);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)