Beispiel #1
0
 [PlatformSpecific(TestPlatforms.Windows)]  // SecureStringToBSTR not supported on Unix
 public static void SecureStringToBSTR(string data)
 {
     using (SecureString str = ToSecureString(data))
     {
         IntPtr bstr = Marshal.SecureStringToBSTR(str);
         try
         {
             string actual = Marshal.PtrToStringBSTR(bstr);
             Assert.Equal(data, actual);
         }
         finally
         {
             Marshal.ZeroFreeBSTR(bstr);
         }
     }
 }