Skip to Main Content
Improving your C# Skills
book

Improving your C# Skills

by Ovais Mehboob Ahmed Khan, John Callaway, Clayton Hunt, Rod Stephens
February 2019
Intermediate to advanced content levelIntermediate to advanced
606 pages
16h 18m
English
Packt Publishing
Content preview from Improving your C# Skills

51. Encrypt and decrypt strings

Before you can use the .NET Framework's cryptography tools to encrypt and decrypt strings (or files, arrays of bytes, or just about anything else), you need to perform some setup. The following method creates an ICryptoTransform object that you can use to encrypt or decrypt data:

// Prepare a cryptographic transformation for this password// and SymmetricAlgorithm.private static ICryptoTransform MakeCryptoTransform(    string password, bool doEncryption, SymmetricAlgorithm cryptoProvider){    // Find a valid key size for this provider.    int numKeyBits = FindKeySize(cryptoProvider);    Console.WriteLine($"Key size: {numKeyBits} bits");    // Get the block size for this provider. int blockSizeBits = cryptoProvider.BlockSize; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Communicate with Teams More Effectively

Communicate with Teams More Effectively

Charles Humble
How to Help High Achievers Overcome Imposter Syndrome

How to Help High Achievers Overcome Imposter Syndrome

Morela Hernandez, Christina Lacerenza

Publisher Resources

ISBN: 9781838558383Supplemental Content