Click here to Skip to main content
15,890,438 members
Home / Discussions / C#
   

C#

 
AnswerRe: String and Byte troubles Pin
Gerald Schwab16-Jan-06 11:09
Gerald Schwab16-Jan-06 11:09 
AnswerRe: String and Byte troubles Pin
Guffa16-Jan-06 11:17
Guffa16-Jan-06 11:17 
GeneralRe: String and Byte troubles Pin
Tom Wright16-Jan-06 11:26
Tom Wright16-Jan-06 11:26 
GeneralRe: String and Byte troubles Pin
Curtis Schlak.16-Jan-06 12:37
Curtis Schlak.16-Jan-06 12:37 
AnswerRe: String and Byte troubles Pin
Guffa16-Jan-06 12:50
Guffa16-Jan-06 12:50 
Questionhow can i make image layer Pin
ugurbil16-Jan-06 9:50
ugurbil16-Jan-06 9:50 
AnswerRe: how can i make image layer Pin
Christian Graus16-Jan-06 11:53
protectorChristian Graus16-Jan-06 11:53 
GeneralRe: how can i make image layer Pin
ugurbil18-Jan-06 2:32
ugurbil18-Jan-06 2:32 
GeneralRe: how can i make image layer Pin
Christian Graus18-Jan-06 9:00
protectorChristian Graus18-Jan-06 9:00 
QuestionCustom Components - Where are they? Pin
redfish3416-Jan-06 7:44
redfish3416-Jan-06 7:44 
AnswerRe: Custom Components - Where are they? Pin
Guffa16-Jan-06 8:16
Guffa16-Jan-06 8:16 
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 

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.