CmisSync.Lib.Config.Crypto.WindowsObfuscate C# (CSharp) Method

WindowsObfuscate() private static method

Obfuscate a string on Windows. We use the recommended API for this: DPAPI (Windows Data Protection API) http://msdn.microsoft.com/en-us/library/ms995355.aspx Warning: Even though it uses the Windows user's password, it is not uncrackable.
private static WindowsObfuscate ( string value ) : string
value string The string to obfuscate
return string
        private static string WindowsObfuscate(string value) {
            #if __MonoCS__
            // This macro prevents compilation errors on Unix where ProtectedData does not exist.
            return "Should never be reached";
            #else
            try {
                byte[] data = System.Text.Encoding.UTF8.GetBytes(value);

                // Encrypt the data using DataProtectionScope.CurrentUser. The result can be decrypted
                //  only by the same current user.
                byte[] crypt = ProtectedData.Protect(data, GetCryptoKey(), DataProtectionScope.CurrentUser);
                return Convert.ToBase64String(crypt, Base64FormattingOptions.None);
            } catch (CryptographicException e) {
                Console.WriteLine("Data was not encrypted. An error occurred.");
                Console.WriteLine(e.ToString());
                return null;
            }
            #endif
        }