Created
May 4, 2018 17:47
-
-
Save jeremybeavon/794d8c916fc0008f84c62a216bc45e19 to your computer and use it in GitHub Desktop.
SecureString helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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