<PackageReference Include="BouncyCastle.Cryptography" Version="2.3.1" />

DerVideotexString

using Org.BouncyCastle.Utilities; using System; using System.IO; namespace Org.BouncyCastle.Asn1 { public class DerVideotexString : DerStringBase { internal class Meta : Asn1UniversalType { internal static readonly Asn1UniversalType Instance = new Meta(); private Meta() : base(typeof(DerVideotexString), 21) { } internal override Asn1Object FromImplicitPrimitive(DerOctetString octetString) { return CreatePrimitive(octetString.GetOctets()); } } private readonly byte[] m_contents; public static DerVideotexString GetInstance(object obj) { if (obj == null) return null; DerVideotexString derVideotexString = obj as DerVideotexString; if (derVideotexString != null) return derVideotexString; IAsn1Convertible asn1Convertible = obj as IAsn1Convertible; if (asn1Convertible != null) { DerVideotexString derVideotexString2 = asn1Convertible.ToAsn1Object() as DerVideotexString; if (derVideotexString2 != null) return derVideotexString2; } else { byte[] array = obj as byte[]; if (array != null) try { return (DerVideotexString)Meta.Instance.FromByteArray(array); } catch (IOException ex) { throw new ArgumentException("failed to construct videotex string from byte[]: " + ex.Message); } } throw new ArgumentException("illegal object in GetInstance: " + Platform.GetTypeName(obj), "obj"); } public static DerVideotexString GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) { return (DerVideotexString)Meta.Instance.GetContextInstance(taggedObject, declaredExplicit); } public DerVideotexString(byte[] contents) : this(contents, true) { } internal DerVideotexString(byte[] contents, bool clone) { if (contents == null) throw new ArgumentNullException("contents"); m_contents = (clone ? Arrays.Clone(contents) : contents); } public override string GetString() { return Strings.FromByteArray(m_contents); } public byte[] GetOctets() { return Arrays.Clone(m_contents); } internal override IAsn1Encoding GetEncoding(int encoding) { return new PrimitiveEncoding(0, 21, m_contents); } internal override IAsn1Encoding GetEncodingImplicit(int encoding, int tagClass, int tagNo) { return new PrimitiveEncoding(tagClass, tagNo, m_contents); } internal sealed override DerEncoding GetEncodingDer() { return new PrimitiveDerEncoding(0, 21, m_contents); } internal sealed override DerEncoding GetEncodingDerImplicit(int tagClass, int tagNo) { return new PrimitiveDerEncoding(tagClass, tagNo, m_contents); } protected override bool Asn1Equals(Asn1Object asn1Object) { DerVideotexString derVideotexString = asn1Object as DerVideotexString; if (derVideotexString != null) return Arrays.AreEqual(m_contents, derVideotexString.m_contents); return false; } protected override int Asn1GetHashCode() { return Arrays.GetHashCode(m_contents); } internal static DerVideotexString CreatePrimitive(byte[] contents) { return new DerVideotexString(contents, false); } } }