Secure your data with ProtectedData and ProtectedMemory using C#
Microsoft OS (XP or later) and .NET provides finest way to secure your data for storage and in-memory. This can be accomplished using following classes from Data Protectection API ProtectedData ProtectedMemory Above mentioned classes can be found in System.Security.Cryptography namespace. Also known as part of DPAPI, they are available since .NET 2.0 ProtectedData ProtectedData can encrypt and decrypt your data symmetrically. To encrypt data following code is used: ProtectedData.Protect(byteArrayOfOriginalData, additionalEntropyOrSalt, DataProtectionScopeValue); To decrypt data following code is used: ProtectedData.Unprotect(byteArrayOfEncryptedData, additionalEntropyOrSalt, DataProtectionScopeValue); In above code snippets additionalEntropyOrSalt can be some custom key / salt value / entropy data that you can add to the encryption / decryption process to increase security strength. DataProtectionScope in above code snippets can have any of the two values: CurrentUser - Allows decryption of encrypted data in current user context only. LocalMachine - Allows decryption of encrypted data in current machine context » Read more