This commit is contained in:
Rene Schwarz
2021-08-06 12:35:46 +02:00
parent 2240d30570
commit 4828f95ebb
59 changed files with 476 additions and 829 deletions

View File

@@ -5,12 +5,19 @@ using System.Security;
using System.Text;
namespace Server_Dashboard {
/// <summary>
/// Secure string helper class to unsecure the Password b4 it goes to the database
/// </summary>
public static class SecureStringHelpers {
//Unsecures a given password
public static string Unsecure(this SecureString secureString) {
//If empty return nothing
if (secureString == null)
return string.Empty;
//New zero pointer
var unmanagedString = IntPtr.Zero;
//Try to unsecure the string
try {
unmanagedString = Marshal.SecureStringToGlobalAllocUnicode(secureString);
return Marshal.PtrToStringUni(unmanagedString);