Click here to Skip to main content
15,911,711 members
Home / Discussions / C#
   

C#

 
GeneralRe: adding components to the designer by code Pin
Roger Alsing12-Oct-03 22:10
Roger Alsing12-Oct-03 22:10 
GeneralCOM+ Pin
devvvy12-Oct-03 1:20
devvvy12-Oct-03 1:20 
GeneralMicrothreads Pin
bjoernen12-Oct-03 0:58
bjoernen12-Oct-03 0:58 
GeneralRe: Microthreads Pin
Blake Coverett12-Oct-03 3:01
Blake Coverett12-Oct-03 3:01 
GeneralRe: Microthreads Pin
Bo Hunter12-Oct-03 7:05
Bo Hunter12-Oct-03 7:05 
GeneralRe: Microthreads Pin
bjoernen12-Oct-03 8:13
bjoernen12-Oct-03 8:13 
GeneralCOM+ and remoting Pin
devvvy11-Oct-03 23:31
devvvy11-Oct-03 23:31 
GeneralProblems with decrypting Pin
Wjousts11-Oct-03 18:08
Wjousts11-Oct-03 18:08 
Does anybody know what I'm doing wrong here? I'm trying to encrypt my class before I serialize it. It seems to encrypt and serialize my class just fine (or at least it managles it into something unreadable!), but when I attempt to deserialize I keep getting either SerializationException "End of Stream encountered before parsing was completed", but it seems to work fine without the encryption. I think it has something to do with the way it handles blocks of data, but I'm not sure how to make it work right.

Thanks

<br />
public void SaveClass()<br />
{<br />
IFormatter BinFmt = new BinaryFormatter();<br />
UnicodeEncoding UE = new UnicodeEncoding();<br />
byte[] key = UE.GetBytes(strUser);<br />
<br />
Stream sout = File.Open("Class.bin",FileMode.Create);<br />
RijndaelManaged myRijndael = new RijndaelManaged();<br />
CryptoStream CptOut = new CryptoStream(sout,myRijndael.CreateEncryptor(key,key),CryptoStreamMode.Write);<br />
BinFmt.Serialize(CptOut,this);<br />
sout.Close();<br />
}<br />
<br />
public static MyClass LoadClass()<br />
{<br />
MyClass newObj = new MyClass();<br />
IFormatter BinFmt = new BinaryFormatter();<br />
UnicodeEncoding UE = new UnicodeEncoding();<br />
string currUser = newObj.strUser;<br />
byte[] key = UE.GetBytes(currUser);<br />
			<br />
Stream sin = File.Open("Class.bin",FileMode.Open);<br />
RijndaelManaged myRijndael = new RijndaelManaged();<br />
CryptoStream Cptin = new CryptoStream(sin,myRijndael.CreateDecryptor(key,key),CryptoStreamMode.Read);<br />
newObj = BinFmt.Deserialize(Cptin) as MyClass;<br />
sin.Close();<br />
return newObj;<br />
}<br />

GeneralBooks on C# Threading... Pin
eggie511-Oct-03 14:46
eggie511-Oct-03 14:46 
GeneralRe: Books on C# Threading... Pin
David Stone11-Oct-03 18:37
sitebuilderDavid Stone11-Oct-03 18:37 
GeneralRe: Books on C# Threading... Pin
Nick Parker12-Oct-03 11:10
protectorNick Parker12-Oct-03 11:10 
GeneralRemote events that instantiate and show new Forms Pin
jerrycainjr11-Oct-03 14:04
jerrycainjr11-Oct-03 14:04 
General3Tier applications and database replicating using C# Pin
DanFreddy11-Oct-03 11:57
DanFreddy11-Oct-03 11:57 
GeneralSerializing and Events Pin
jparsons11-Oct-03 9:49
jparsons11-Oct-03 9:49 
GeneralRe: Serializing and Events Pin
leppie11-Oct-03 23:22
leppie11-Oct-03 23:22 
GeneralRe: Serializing and Events Pin
jparsons12-Oct-03 13:31
jparsons12-Oct-03 13:31 
GeneralTypeInitializationException and Windows Service Pin
devvvy11-Oct-03 9:28
devvvy11-Oct-03 9:28 
GeneralGenerating public and private keys... Pin
Meysam Mahfouzi11-Oct-03 7:24
Meysam Mahfouzi11-Oct-03 7:24 
GeneralRe: Generating public and private keys... Pin
Blake Coverett11-Oct-03 10:17
Blake Coverett11-Oct-03 10:17 
GeneralRe: Generating public and private keys... Pin
Meysam Mahfouzi11-Oct-03 20:19
Meysam Mahfouzi11-Oct-03 20:19 
GeneralRe: Generating public and private keys... Pin
Blake Coverett11-Oct-03 20:44
Blake Coverett11-Oct-03 20:44 
GeneralRe: Generating public and private keys... Pin
Meysam Mahfouzi12-Oct-03 17:19
Meysam Mahfouzi12-Oct-03 17:19 
GeneralRe: Generating public and private keys... Pin
Meysam Mahfouzi14-Oct-03 18:08
Meysam Mahfouzi14-Oct-03 18:08 
GeneralRemoving Windows Services and event log Pin
devvvy11-Oct-03 5:26
devvvy11-Oct-03 5:26 
GeneralRe: Removing Windows Services and event log Pin
Daniel M. Edwards11-Oct-03 6:25
Daniel M. Edwards11-Oct-03 6:25 

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.