Skip to content

Instantly share code, notes, and snippets.

@jeremybeavon
Created May 4, 2018 17:47
Show Gist options
  • Save jeremybeavon/794d8c916fc0008f84c62a216bc45e19 to your computer and use it in GitHub Desktop.
Save jeremybeavon/794d8c916fc0008f84c62a216bc45e19 to your computer and use it in GitHub Desktop.
SecureString helper
using System.Net;
using System.Security;
public static class SecureStringHelper
{
public static SecureString ToSecureString(this string plaintext)
{
return new NetworkCredential("N/A", plaintext).SecurePassword;
}
public static string ToPlainTextString(this SecureString secureString)
{
return new NetworkCredential("N/A", secureString).Password;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment