31 lines
974 B
C#
31 lines
974 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Security;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BodyshopUploader.Utils
|
|
{
|
|
public static class LoginHelpers
|
|
{
|
|
public static void SaveLoginSettings(string Username, SecureString Password)
|
|
{
|
|
Properties.Settings.Default.Username = Username;
|
|
//Todo: Figure out how to save the secure string. Perhaps serialize to JSON?
|
|
Properties.Settings.Default.Password = Password;
|
|
Properties.Settings.Default.Save();
|
|
}
|
|
|
|
public static string DecodePassword (SecureString s)
|
|
{
|
|
//Manage the secure string for the password.
|
|
IntPtr stringPointer = Marshal.SecureStringToBSTR(s);
|
|
string UP = Marshal.PtrToStringBSTR(stringPointer);
|
|
Marshal.ZeroFreeBSTR(stringPointer);
|
|
return UP;
|
|
}
|
|
}
|
|
}
|