Initial Comit
This commit is contained in:
39
Helper/Base64Helper.cs
Normal file
39
Helper/Base64Helper.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
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
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user