Encrypting data not files...
-
Hi, I'm trying to encrypt data in a large text control on a C# windows form. Can anyone tell me how to encrypt and decrypt the data that's in just the text control? I've seen instances on how to encrypt and decrypt files, but not strings of data. I don't need any particular algorithm, but lets just say DESCryptoServiceProvider as an example. Thanks ;)
-
Hi, I'm trying to encrypt data in a large text control on a C# windows form. Can anyone tell me how to encrypt and decrypt the data that's in just the text control? I've seen instances on how to encrypt and decrypt files, but not strings of data. I don't need any particular algorithm, but lets just say DESCryptoServiceProvider as an example. Thanks ;)
A file is just a stream, or an array of bytes. While the examples might use a
FileStream
, you could use aMemoryStream
or even aStringReader
, all from theSystem.IO
namespace. Instead of relying on the examples, though, make sure you read the documentation to understand what's required. After all, a string is just an array of bytes, it's only handled differently. To get a string of bytes in a particular encoding, see the documentation forSystem.Text.Encoding
in the .NET Framework SDK as well.Microsoft MVP, Visual C# My Articles