web-app-template/backend/app/app.CredentialManager/Base64.cs
2022-02-20 13:57:55 +01:00

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};";
}
}
}