O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Encrypt an Object

Problem

You want to use encryption on an entire object, not just individual pieces of data.

Solution

Use .NET serialization to convert the object to a stream of bytes, and encrypt the serialized data.

Discussion

Recipes Serialize an Object to Disk, Serialize Public Members of a Nonserializable Object, and Perform Selective Serialization with the Memento Pattern demonstrated different ways to serialize an object to a stream of bytes. You can use this technique in conjunction with symmetric or asymmetric encryption to encrypt the contents of a serializable object. If you’re using asymmetric encryption, you’ll need to convert the object to an array of bytes and then encrypt these bytes one block at a time. If you’re using symmetric encryption, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required