You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.0 KiB
40 lines
1.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Helper
|
|
{
|
|
public class Base64Helper
|
|
|
|
{
|
|
public string Base64 { get; set; } = string.Empty;
|
|
|
|
public string Base64Encoded { get; set; } = string.Empty;
|
|
|
|
public string GetBase64() => Base64.EncodeBase64();
|
|
|
|
public string DecodeBase64() => Base64.DecodeBase64();
|
|
}
|
|
public static class EncodeExtensions
|
|
{
|
|
public static string EncodeBase64(this string text) =>
|
|
Convert.ToBase64String(Encoding.ASCII.GetBytes(text.ToString() ?? throw new Exception("T Base64 is null.")));
|
|
|
|
public static string DecodeBase64(this string base64) =>
|
|
Encoding.UTF8.GetString(Convert.FromBase64String(base64 ?? throw new Exception("String Base64 is null.")));
|
|
|
|
public static byte[] DecodeBase642ByteArray(string base64) =>
|
|
Convert.FromBase64String(base64 ?? throw new Exception("String Base64 is null."));
|
|
|
|
}
|
|
}
|
|
|
|
public class MyStringBase64
|
|
{
|
|
|
|
}
|
|
|
|
|