Click here to Skip to main content
15,886,857 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
I have got a build error in the following code....

C#
string password = "Global12$";
string userName = @"myindia.local\Administrator";
SecureString ss = ConvertToSecureString(password);


This is the error message

C#
The name 'ConvertToSecureString' does not exist in the current context


I don't know how to solve this? Which namespace is missing? Any help on this would be great.

Thanks & Regards
Sebastian
Posted
Updated 17-Jun-12 19:20pm
v2
Comments
ZurdoDev 15-Jun-12 8:58am    
A quick google search indicates using ConvertTo-SecureString. Have you tried that?
Sebastian T Xavier 15-Jun-12 9:22am    
If you can show some examples of this , that would be great!!!

Not sure if this is what you're looking for, but try this link:
ConvertToSecureString Class[^] on MSDN.
It has some examples there.
Edited: This can't be the right answer :)

On second thought look at the comments at the bottom here[^]

Maybe that's where this mysterious method came from ;)

C#
private SecureString ConvertToSecureString(string value)
{
    SecureString ret = new SecureString();
    foreach (char c in value)
    {
        ret.AppendChar(c);
    }
    ret.MakeReadOnly();
    return ret;
}
 
Share this answer
 
v3
ConvertToSecureString is a private method , which you need to write in your own class.

As mentioned http://msdn.microsoft.com/en-us/library/system.security.securestring.aspx[^], you need to write your own version of ConvertToSecureString method.

Thanks
Rushikesh Joshi
 
Share this answer
 
Comments
Sebastian T Xavier 18-Jun-12 1:19am    
Thanks for your reply. But I think , I am looking for another method. Please have a look at the following URL. http://msdn.microsoft.com/en-us/library/microsoft.powershell.security.activities.converttosecurestring(v=vs.85).aspx.

Regards
Sebastian

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900