complete login function and login window also add attached properties and helper classes for securestring
This commit is contained in:
22
Server Dashboard/Security/SecureStringHelpers.cs
Normal file
22
Server Dashboard/Security/SecureStringHelpers.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
|
||||
namespace Server_Dashboard {
|
||||
public static class SecureStringHelpers {
|
||||
public static string Unsecure(this SecureString secureString) {
|
||||
if (secureString == null)
|
||||
return string.Empty;
|
||||
var unmanagedString = IntPtr.Zero;
|
||||
|
||||
try {
|
||||
unmanagedString = Marshal.SecureStringToGlobalAllocUnicode(secureString);
|
||||
return Marshal.PtrToStringUni(unmanagedString);
|
||||
} finally {
|
||||
Marshal.ZeroFreeGlobalAllocUnicode(unmanagedString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user