PC Review


Reply
Thread Tools Rate Thread

DESCryptoServiceProvider

 
 
Ondrej Sevecek
Guest
Posts: n/a
 
      2nd Mar 2005
Hello,

would you please provide me with some simple sample of how to use the
DESCryptoServiceProvider to encrypt a buffer

byte[] buffer;

with key

byte[] key;

produceing cipher text:

byte[] ciphertext;

I saw some sample using Streams, but is there a simpler method working for
buffers?

O.



 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      2nd Mar 2005
<"Ondrej Sevecek" <ondra_at_sevecek_dt_com>> wrote:
> Hello,
>
> would you please provide me with some simple sample of how to use the
> DESCryptoServiceProvider to encrypt a buffer
>
> byte[] buffer;
>
> with key
>
> byte[] key;
>
> produceing cipher text:
>
> byte[] ciphertext;
>
> I saw some sample using Streams, but is there a simpler method working for
> buffers?


You need to use a stream at some stage, but using MemoryStream and its
ToArray method make it easy to return a byte array.

Basically, just create a MemoryStream, then an appropriate CryptoStream
to write into that. Write your original buffer into the CryptoStream,
close it (which will do the appropriate FlushFinalBlock - just
disposing of it won't, due to a bug in 1.1), and then call ToArray on
the MemoryStream.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Abount DESCryptoServiceProvider wolf Microsoft Dot NET Framework 3 21st Mar 2005 06:13 PM
about DESCryptoServiceProvider creative Microsoft Dot NET Framework 1 30th Dec 2004 09:07 AM
DESCryptoServiceProvider Microsoft C# .NET 1 27th Jan 2004 01:45 PM
DESCryptoServiceProvider Microsoft Dot NET 1 27th Jan 2004 01:45 PM
DESCryptoServiceProvider Microsoft Dot NET Framework 1 27th Jan 2004 01:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:37 PM.