getting there
This commit is contained in:
20
PVHelpers/Base64Helpers.cs
Normal file
20
PVHelpers/Base64Helpers.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user