25 lines
809 B
C#
25 lines
809 B
C#
|
using System;
|
||
|
|
||
|
namespace app.CredentialManager
|
||
|
{
|
||
|
public static class Base64
|
||
|
{
|
||
|
public static string Encode(string credentials)
|
||
|
{
|
||
|
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(credentials);
|
||
|
return System.Convert.ToBase64String(plainTextBytes);
|
||
|
}
|
||
|
|
||
|
public static string Decode(string credentials)
|
||
|
{
|
||
|
var base64EncodedBytes = System.Convert.FromBase64String(credentials);
|
||
|
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
|
||
|
}
|
||
|
|
||
|
public static string DecodeConnectionString(string connectionString, string credentials)
|
||
|
{
|
||
|
string decodedCredentials = Decode(credentials);
|
||
|
return connectionString += $"password={decodedCredentials};";
|
||
|
}
|
||
|
}
|
||
|
}
|