You guys how are you?
Me i am not fine because of
1. I am trying to read data from a file
2. encrypt that data
3. disply the encryptd data on the console
4. How??? using the TrippleDES Algorithm
——————————————-
Problem:
1. suppose the file has the content hallo, or jane or 123 ie; few character, then NOTHING IS ENCRYPTED, I GET NO OUTPUT WHATSOEVER.
2. but when file has the content like “i am really getting pisssed off!” ie; long text; the D**N thing displays something!!
3. When i decrypt using simillar code, The last few character of the orginal text dont show; ie partial decryption.
SO PLEASE SOMEONE HELP!
IN THE MEANTIME, I WILL GO BUY PAIN KILLERS TO CALM DOWN THIS HEADACHE!
Below is my code
——————————–
using System;
using System.Security.Cryptography;
using System.IO;
using System.Text;
namespace TRIPPLEDES
{
class FileCipherer
{
[STAThread]
static void Main(string[] args)
{
System.IO.StreamReader inputstream = new StreamReader(new FileStream(”C:/data.txt”,FileMode.Open));
byte[] data=ASCIIEncoding.ASCII.GetBytes(inputstream.ReadToEnd());
System.Security.Cryptography.TripleDES tdes=System.Security.Cryptography.TripleDESCryptoServiceProvider.Create();
tdes.Key=ASCIIEncoding.ASCII.GetBytes(”12345678!@#$%^&*”);
tdes.IV=ASCIIEncoding.ASCII.GetBytes(”!@12nhuo”);
tdes.Mode=CipherMode.CBC;
System.Security.Cryptography.ICryptoTransform encryptor=tdes.CreateEncryptor();
System.Security.Cryptography.CryptoStream tdes_stream = new CryptoStream(Console.OpenStandardOutput(),encryptor,CryptoStreamMode.Write);
tdes_stream.Write(data,0,data.Length);
Console.WriteLine(”Completed!”);
}
}
}
Related posts:








2 responses so far ↓
1 STARBUCKS RULES!!! // Sep 29, 2008
You need to calm down
2 Rah-Mon Heur // Sep 29, 2008
When you paste code into a yahoo question, you need to format it so that the lines fit otherwise they are truncated and we can’t read (and try) your code.
I suggest you re-post your code splitting the lines so that every line fit.
As for your problem, I’m not familiar enough with those functions to tell you exactly where the problem is, but in both case it look like either the buffer sent to the encrypting function is incomplete, or most probably the resulting string is not flushed to disk completely before it is displayed, truncating the last data that are still in internal buffer.
Leave a Comment