views:

419

answers:

5

Well the title says it all :P is there any way to encrypt a bytearray without using a stream??

+1  A: 

Well, you could write your own encryption algorithms - but it's much easier just to use the built-in streaming API writing to a MemoryStream which you then convert to a byte array using ToArray.

Jon Skeet
+5  A: 

If you are concerned about disk I/O you can use a MemoryStream.

However, the RSACryptoServiceProvider class will operate on byte arrays. This class performs asymmetric encryption and decryption using an implementation of the RSA algorithm.

The examples here show how you can do this with byte arrays

Noah
A: 

Use a block cypher and implement it yourself.

But this is almost certainly pointless since using a MemoryStream on the byte array should work just fine and will use a well tested implementation.

Implementing something yourself when you're talking about crypto is normally a bad idea.

ShuggyCoUk
A: 

Using the Cryptography Application Block of Microsofts Enterprise Library you can do this, but I agree with the others that you don't really get any benefits from not using a stream.

Rune Grimstad