How to encrypt while using BinaryFormatter?

  • Thread starter Thread starter assaf
  • Start date Start date
A

assaf

hi all

i am using des symmetric crypto.
i need to encrypt my app packets.

i use XmlSerializer,
to serialize my packets into a memory stream.
i then extract the byte array.

i encrypt this array,
and all works well.


however, when i use a BinaryFormatter,
instead of the XmlSerializer,
the Deserialize fails!


what must i do in order to encrypt while using BinaryFormatter?


assaf
 
hi all

sorry.
my mistake.
XmlSerializer does not work as well.

how to encrypt binary data in any way?

assaf
 
assaf said:
sorry.
my mistake.
XmlSerializer does not work as well.

how to encrypt binary data in any way?

Just use the crypto stream API. Have a look at the docs for CrypoStream
for an example.
 
hi jon

the samples are all
1. for files
2. for strings

we on the contrary have binary data.
and i am unable to find any sample code.

help me plz.

assaf
 
assaf said:
hi jon

the samples are all
1. for files
2. for strings

we on the contrary have binary data.
and i am unable to find any sample code.

See the example you find in the CryptoStream docs.

ciao
Rob
 
assaf said:
the samples are all
1. for files
2. for strings

we on the contrary have binary data.
and i am unable to find any sample code.

1) Use a different stream instead of FileStream
2) The example in "about CryptoStream" doesn't use strings - it's
encrypting one file and writing it out as another

Try following the example through, line by line, and you'll see how to
use CryptoStream for your case.
 
Back
Top