Getting ready

The code might look a little funny in some places. This is because SecureString is using unmanaged memory to store the sensitive information. Rest assured that SecureString is well supported and used within the .NET Framework, as can be seen from the instantiation of the SqlCredential object used in creating connections to a database:

Get C# 7 and .NET Core Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.