Protect string content by marshalling
1 2 IntPtr bstr = Marshal.SecureStringToBSTR(password); 3 4 try 5 { 6 // ... 7 // use the bstr 8 // ... 9 } 10 finally 11 { 12 Marshal.ZeroFreeBSTR(bstr); 13 } 14
DZone Snippets > mstampar > marshalling
12724 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Miroslav Stampar http://mstampar.awardspace.com
1 2 IntPtr bstr = Marshal.SecureStringToBSTR(password); 3 4 try 5 { 6 // ... 7 // use the bstr 8 // ... 9 } 10 finally 11 { 12 Marshal.ZeroFreeBSTR(bstr); 13 } 14