473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

DESCryptoServiceProvider

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.

Jul 21 '05 #1
1 3006
<"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 - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Salman | last post by:
When I run the below method with a 64 character string as input such as: sr.Encrypt("1234567890123456789012345678901234567890123456789012345678904444"); I get square boxes as my output, which...
2
by: Tom | last post by:
Hi experts, I have the following code, which works fine: ######################### C# snippet ######################################## string k = "12345678"; string input = "ABCDEFGH"; ...
3
by: wolf | last post by:
Can I de-crypt the data by java which is crypt by DESCryptoServiceProvider? The following is my code to crypt data: string text = "This is My source data"; byte source =...
8
by: Gidi | last post by:
Hi, Is there Buid-In fuction in C# that Encrypt and Decrypt strings? i have a textbox which i'm writing into file, and i want to encrypt it before writing, i'm not looking for something fancy,...
5
by: Joe | last post by:
I'm trying to figure out how to remove the characters padded to the end of my string without setting the Padding = PaddingMode.None. My original string passed in is 'passwordTest' and the...
5
by: Sia Jai Sung | last post by:
Hi, I have a class that I modify from a sample program, like below ========================================== Imports System Imports System.Web.UI Imports System.Security.Cryptography ...
1
by: Ondrej Sevecek | last post by:
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;
4
by: Andreas Pauley | last post by:
Hi all, I'm trying to implement a Python equivalent of a C# method that encrypts a string. My Python attempt is in the attached file, but does not return the same value as the C# method (see...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.