init commit

This commit is contained in:
2025-10-09 09:57:24 +09:00
commit 4d551bd74f
6636 changed files with 1218703 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
using System;
using System.IO;
namespace Org.BouncyCastle.Utilities.Encoders;
public class UrlBase64
{
private static readonly IEncoder encoder = new UrlBase64Encoder();
public static byte[] Encode(byte[] data)
{
MemoryStream memoryStream = new MemoryStream();
try
{
encoder.Encode(data, 0, data.Length, memoryStream);
}
catch (IOException ex)
{
throw new Exception("exception encoding URL safe base64 string: " + ex.Message, ex);
}
return memoryStream.ToArray();
}
public static int Encode(byte[] data, Stream outStr)
{
return encoder.Encode(data, 0, data.Length, outStr);
}
public static byte[] Decode(byte[] data)
{
MemoryStream memoryStream = new MemoryStream();
try
{
encoder.Decode(data, 0, data.Length, memoryStream);
}
catch (IOException ex)
{
throw new Exception("exception decoding URL safe base64 string: " + ex.Message, ex);
}
return memoryStream.ToArray();
}
public static int Decode(byte[] data, Stream outStr)
{
return encoder.Decode(data, 0, data.Length, outStr);
}
public static byte[] Decode(string data)
{
MemoryStream memoryStream = new MemoryStream();
try
{
encoder.DecodeString(data, memoryStream);
}
catch (IOException ex)
{
throw new Exception("exception decoding URL safe base64 string: " + ex.Message, ex);
}
return memoryStream.ToArray();
}
public static int Decode(string data, Stream outStr)
{
return encoder.DecodeString(data, outStr);
}
}