<PackageReference Include="BouncyCastle.Cryptography" Version="2.7.0-beta.98" />

Utilities

static class Utilities
using Org.BouncyCastle.Crypto.Utilities; using System; namespace Org.BouncyCastle.Bcpg.Sig { internal static class Utilities { internal static bool BooleanFromBytes(byte[] bytes) { if (bytes.Length != 1) throw new InvalidOperationException("Byte array has unexpected length. Expected length 1, got " + bytes.Length.ToString()); byte b = bytes[0]; if (b > 1) throw new InvalidOperationException("Unexpected byte value for boolean encoding: " + b.ToString()); return Convert.ToBoolean(b); } internal static byte[] BooleanToBytes(bool value) { return new byte[1] { Convert.ToByte(value) }; } internal static uint TimeFromBytes(byte[] bytes) { if (bytes.Length != 4) throw new InvalidOperationException("Byte array has unexpected length. Expected length 4, got " + bytes.Length.ToString()); return Pack.BE_To_UInt32(bytes); } internal static byte[] TimeToBytes(uint t) { return Pack.UInt32_To_BE(t); } } }