- Initial commit

This commit is contained in:
Timur Kozanov
2026-07-03 05:02:26 +03:00
commit 374ff1e689
4080 changed files with 388870 additions and 0 deletions

View File

@ -0,0 +1,98 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using System.IO;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
{
public static class BinaryReaders
{
public static byte[] ReadBytesFully(BinaryReader binaryReader, int count)
{
byte[] bytes = binaryReader.ReadBytes(count);
if (bytes == null || bytes.Length != count)
throw new EndOfStreamException();
return bytes;
}
public static short ReadInt16BigEndian(BinaryReader binaryReader)
{
short n = binaryReader.ReadInt16();
return BitConverter.IsLittleEndian ? Shorts.ReverseBytes(n) : n;
}
public static short ReadInt16LittleEndian(BinaryReader binaryReader)
{
short n = binaryReader.ReadInt16();
return BitConverter.IsLittleEndian ? n : Shorts.ReverseBytes(n);
}
public static int ReadInt32BigEndian(BinaryReader binaryReader)
{
int n = binaryReader.ReadInt32();
return BitConverter.IsLittleEndian ? Integers.ReverseBytes(n) : n;
}
public static int ReadInt32LittleEndian(BinaryReader binaryReader)
{
int n = binaryReader.ReadInt32();
return BitConverter.IsLittleEndian ? n : Integers.ReverseBytes(n);
}
public static long ReadInt64BigEndian(BinaryReader binaryReader)
{
long n = binaryReader.ReadInt64();
return BitConverter.IsLittleEndian ? Longs.ReverseBytes(n) : n;
}
public static long ReadInt64LittleEndian(BinaryReader binaryReader)
{
long n = binaryReader.ReadInt64();
return BitConverter.IsLittleEndian ? n : Longs.ReverseBytes(n);
}
[CLSCompliant(false)]
public static ushort ReadUInt16BigEndian(BinaryReader binaryReader)
{
ushort n = binaryReader.ReadUInt16();
return BitConverter.IsLittleEndian ? Shorts.ReverseBytes(n) : n;
}
[CLSCompliant(false)]
public static ushort ReadUInt16LittleEndian(BinaryReader binaryReader)
{
ushort n = binaryReader.ReadUInt16();
return BitConverter.IsLittleEndian ? n : Shorts.ReverseBytes(n);
}
[CLSCompliant(false)]
public static uint ReadUInt32BigEndian(BinaryReader binaryReader)
{
uint n = binaryReader.ReadUInt32();
return BitConverter.IsLittleEndian ? Integers.ReverseBytes(n) : n;
}
[CLSCompliant(false)]
public static uint ReadUInt32LittleEndian(BinaryReader binaryReader)
{
uint n = binaryReader.ReadUInt32();
return BitConverter.IsLittleEndian ? n : Integers.ReverseBytes(n);
}
[CLSCompliant(false)]
public static ulong ReadUInt64BigEndian(BinaryReader binaryReader)
{
ulong n = binaryReader.ReadUInt64();
return BitConverter.IsLittleEndian ? Longs.ReverseBytes(n) : n;
}
[CLSCompliant(false)]
public static ulong ReadUInt64LittleEndian(BinaryReader binaryReader)
{
ulong n = binaryReader.ReadUInt64();
return BitConverter.IsLittleEndian ? n : Longs.ReverseBytes(n);
}
}
}
#pragma warning restore
#endif