views:

141

answers:

3

Hello, I am trying to convert an assembly compiled using ICodeCompiler into byte[]. How can I do that? Also what is safest way to transfer this assembly to some remote location (client)? Note that Symmetric Key encyrption is not a possiblity.

Update: What about this?

        BinaryFormatter formatter = new BinaryFormatter();
        MemoryStream assemblyStream = new MemoryStream();
        formatter.Serialize(assemblyStream, loAssembly);

How do I transfer the byte[] ?

+2  A: 

Last time I checked files were usually stored as bytes on a hard drive.

So what is your exact problem?

leppie
+1  A: 

Save the assembly using one of the Stream based method overloads to a MemoryStream instance. You can then read the byte[] stream back out from the MemoryStream.

-Oisin

x0n
A: 

Answering the transfer issue, it depends on your level of paranoia and the exact situation you're in. There are a wide variety of encryption schemes available that you can choose from (wikipedia has plenty of details on such), as well as transfer options you might have available to you. Sending a hard copy, or over the wire? Email, ftp, ssh ftp? What about the transfer concerns you - ie at what point(s) in the transfer between your hands and the destination do you feel that security could be breached? How about before and after the transfer? Once you know what those specific issues are, you'll be more able to address the issue of what defines "safest" for you.

patjbs