Discussion on:

5
Comments

Join the conversation!

Follow via:
RSS
Email Alert
1 Vote
+ -
You say "You?ll notice the code simply displays the name of the class (System.Security.SecureString) when it executes." This is incorrect. The output is "TechRepublic.com". The editor owes me a brewski.


doug in Seattle
0 Votes
+ -
Output IS correct
KeeBored 13th Jun 2007
At least for me it is. I am running the code in version 2.0.50727 of the framework and it does output the name of the class, not the contents.

One thing worth noticing though is that the VB.NET class has only one constructor with no arguments as VB.NET does not provide pointer functionality and the AppendChar lines will blow if you have OPTION STRICT ON unless you explicitly cast the values to Char type. In C# that is not the case since single quote denotes Char and Double quote denotes String.
0 Votes
+ -
example typo
aikimark@... Updated - 13th Jun 2007
You have an example type in the "Getting the data" section.

"IntPtr pointerName ="
and
".PtrToStringBSTR(bstr));"

are inconsistent. One of them should be changed to be consistent with later examples.
Calling to Marshal.PtrToStringBSTR(ptr) creates a System.String that has the same content with ss. You end up having another copy of the password that has all the problem that you try to avoid in the first place. It defeats the purpose of having SecureString.
Lets assume i have one connection string defined in Module which has sensitive db pass n other information which i seldom use it in all my forms.

here you use console.writeline method which is accomplished once, and pointer is terminated, cleared thereafter. but in my case there is no certainty about how long do i need to use my "connectionstring". How can i secure string with this method, keeping in mind i need to use it again n again.
Keyboard Shortcuts:
Prev
Next
Toggle
Join the conversation
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.