Click here to Skip to main content
15,881,757 members
Home / Discussions / C#
   

C#

 
GeneralI Got It! I think? Pin
redfish3416-Jan-06 9:19
redfish3416-Jan-06 9:19 
GeneralRe: I Got It! I think? Pin
J4amieC16-Jan-06 21:57
J4amieC16-Jan-06 21:57 
QuestionSend a double click? Pin
melanieab16-Jan-06 7:15
melanieab16-Jan-06 7:15 
AnswerRe: Send a double click? Pin
Judah Gabriel Himango16-Jan-06 8:32
sponsorJudah Gabriel Himango16-Jan-06 8:32 
QuestionJoinMulticastGroup from multiple processes on same machine Pin
John Fisher16-Jan-06 6:30
John Fisher16-Jan-06 6:30 
QuestionEncryption and Decryption Problems Pin
thepolishguy16-Jan-06 5:49
thepolishguy16-Jan-06 5:49 
AnswerRe: Encryption and Decryption Problems Pin
John Fisher16-Jan-06 6:23
John Fisher16-Jan-06 6:23 
GeneralRe: Encryption and Decryption Problems Pin
thepolishguy16-Jan-06 6:37
thepolishguy16-Jan-06 6:37 
Okay, here's the code I'm using to encrypt:

public void EncryptData()
{
FileStream fs=null;
if(File.Exists(Directory.GetCurrentDirectory() + "\\c#.ini") == false)
{
fs=new FileStream(Directory.GetCurrentDirectory() + "\\c#.ini",
System.IO.FileMode.CreateNew);

}
else
{
fs=new FileStream(Directory.GetCurrentDirectory() + "\\c#.ini",
System.IO.FileMode.Append);
}


byte[] Key = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16};
byte[] IV = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16};

RijndaelManaged RMCrypto=new RijndaelManaged();
System.Security.Cryptography.CryptoStream cryption=new CryptoStream(fs,
RMCrypto.CreateEncryptor(Key, IV), CryptoStreamMode.Write);
StreamWriter tnWriter2 = new StreamWriter(cryption,
System.Text.Encoding.Unicode);
tnWriter2.WriteLine(log);
tnWriter2.Close();
fs.Close();
}

And here's the code for Decrypting:

private void DecryptDataLog()
{
FileStream read=new FileStream(currPath + "\\c#.ini",
System.IO.FileMode.OpenOrCreate);

byte[] Key = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16};
byte[] IV = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16};

RijndaelManaged RMCrypto=new RijndaelManaged();
System.Security.Cryptography.CryptoStream cryption=new CryptoStream(read,
RMCrypto.CreateDecryptor(Key, IV), CryptoStreamMode.Read);
StreamReader tnReader = new StreamReader(cryption,
System.Text.Encoding.Unicode);
this.textBox1.Text=tnReader.ReadToEnd();

tnReader.Close();
read.Close();


}

When the file I'm writing to has more than one line, the first few characters of the 2nd, 3rd, etc lines of encrypted text show up as gibberish, while the rest of the line is OK.


GeneralRe: Encryption and Decryption Problems Pin
John Fisher16-Jan-06 6:50
John Fisher16-Jan-06 6:50 
GeneralRe: Encryption and Decryption Problems Pin
thepolishguy16-Jan-06 7:03
thepolishguy16-Jan-06 7:03 
GeneralRe: Encryption and Decryption Problems Pin
John Fisher16-Jan-06 8:20
John Fisher16-Jan-06 8:20 
GeneralRe: Encryption and Decryption Problems Pin
thepolishguy16-Jan-06 8:29
thepolishguy16-Jan-06 8:29 
GeneralRe: Encryption and Decryption Problems Pin
John Fisher16-Jan-06 8:33
John Fisher16-Jan-06 8:33 
GeneralRe: Encryption and Decryption Problems Pin
thepolishguy16-Jan-06 8:52
thepolishguy16-Jan-06 8:52 
GeneralRe: Encryption and Decryption Problems Pin
John Fisher16-Jan-06 9:09
John Fisher16-Jan-06 9:09 
AnswerRe: Encryption and Decryption Problems Pin
Guffa16-Jan-06 8:21
Guffa16-Jan-06 8:21 
QuestionPrevent Multiple Forms Pin
dimx216-Jan-06 4:49
dimx216-Jan-06 4:49 
AnswerRe: Prevent Multiple Forms Pin
exhaulted16-Jan-06 5:11
exhaulted16-Jan-06 5:11 
AnswerRe: Prevent Multiple Forms Pin
tarasn16-Jan-06 5:16
tarasn16-Jan-06 5:16 
GeneralRe: Prevent Multiple Forms Pin
dimx216-Jan-06 5:54
dimx216-Jan-06 5:54 
AnswerRe: Prevent Multiple Forms Pin
microsoc16-Jan-06 15:57
microsoc16-Jan-06 15:57 
AnswerRe: Prevent Multiple Forms Pin
Hesham Desouky16-Jan-06 22:17
Hesham Desouky16-Jan-06 22:17 
QuestionSize of the object Pin
vSoares16-Jan-06 4:49
professionalvSoares16-Jan-06 4:49 
AnswerRe: Size of the object Pin
John Fisher16-Jan-06 6:20
John Fisher16-Jan-06 6:20 
Questionclosing an application Pin
Mridang Agarwalla16-Jan-06 4:42
Mridang Agarwalla16-Jan-06 4:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.