21 lines
557 B
C#
21 lines
557 B
C#
using System.Buffers.Text;
|
|
using System.Text;
|
|
|
|
namespace PVHelpers
|
|
{
|
|
public static class Base64Helpers
|
|
{
|
|
public static String EncodeBase64String(this Byte[] data)
|
|
{
|
|
Byte[] buf = new Byte[data.Length * 2];
|
|
if (Base64.EncodeToUtf8(data, buf, out _, out Int32 written) == System.Buffers.OperationStatus.Done)
|
|
{
|
|
return Encoding.UTF8.GetString(buf, 0, written);
|
|
} else
|
|
{
|
|
throw new Exception("Shit went south");
|
|
}
|
|
}
|
|
}
|
|
}
|