本文整理汇总了C#中AsnType.GetBytes方法的典型用法代码示例。如果您正苦于以下问题:C# AsnType.GetBytes方法的具体用法?C# AsnType.GetBytes怎么用?C# AsnType.GetBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AsnType
的用法示例。
在下文中一共展示了AsnType.GetBytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSequenceOf
/// <summary>
/// <para>An ordered collection zero, one or more types.
/// Returns the AsnType representing an ASN.1 encoded sequence.</para>
/// <para>If the AsnType value is null,an
/// empty sequence (length 0) is returned.</para>
/// </summary>
/// <param name="value">An AsnType consisting of
/// a single value to be encoded.</param>
/// <returns>Returns the AsnType representing an ASN.1
/// encoded sequence.</returns>
/// <seealso cref="CreateSet(AsnType)"/>
/// <seealso cref="CreateSet(AsnType[])"/>
/// <seealso cref="CreateSetOf(AsnType)"/>
/// <seealso cref="CreateSetOf(AsnType[])"/>
/// <seealso cref="CreateSequence(AsnType)"/>
/// <seealso cref="CreateSequence(AsnType[])"/>
/// <seealso cref="CreateSequenceOf(AsnType)"/>
/// <seealso cref="CreateSequenceOf(AsnType[])"/>
internal static AsnType CreateSequenceOf(AsnType value)
{
// From the ASN.1 Mailing List
if (IsEmpty(value))
{ return new AsnType(0x30, EMPTY); }
// Sequence: Tag 0x30 (16, Universal, Constructed)
return new AsnType(0x30, value.GetBytes());
}
示例2: CreateOctetString
/// <summary>
/// An ordered sequence of zero, one or more octets. Returns
/// the byte[] representing an ASN.1 encoded octet string.
/// If octets is null or length is 0, an empty (0 length)
/// o ctet string is returned.
/// </summary>
/// <param name="value">An AsnType object to be encoded.</param>
/// <returns>Returns the AsnType representing an ASN.1
/// encoded octet string.</returns>
/// <seealso cref="CreateBitString(byte[])"/>
/// <seealso cref="CreateBitString(byte[], uint)"/>
/// <seealso cref="CreateBitString(AsnType)"/>
/// <seealso cref="CreateBitString(String)"/>
/// <seealso cref="CreateOctetString(byte[])"/>
/// <seealso cref="CreateOctetString(String)"/>
internal static AsnType CreateOctetString(AsnType value)
{
if (IsEmpty(value))
{
// Empty octet string
return new AsnType(0x04, 0x00);
}
// OctetString: Tag 0x04 (4, Universal, Primitive)
return new AsnType(0x04, value.GetBytes());
}
示例3: CreateSequence
/// <summary>
/// <para>An ordered collection of one or more types.
/// Returns the AsnType representing an ASN.1 encoded sequence.</para>
/// <para>If the AsnType is null, an empty sequence (length 0)
/// is returned.</para>
/// </summary>
/// <param name="value">An AsnType consisting of
/// a single value to be encoded.</param>
/// <returns>Returns the AsnType representing an ASN.1
/// encoded sequence.</returns>
/// <seealso cref="CreateSet(AsnType)"/>
/// <seealso cref="CreateSet(AsnType[])"/>
/// <seealso cref="CreateSetOf(AsnType)"/>
/// <seealso cref="CreateSetOf(AsnType[])"/>
/// <seealso cref="CreateSequence(AsnType)"/>
/// <seealso cref="CreateSequence(AsnType[])"/>
/// <seealso cref="CreateSequenceOf(AsnType)"/>
/// <seealso cref="CreateSequenceOf(AsnType[])"/>
internal static AsnType CreateSequence(AsnType value)
{
// Should be at least 1...
Debug.Assert(!IsEmpty(value));
// One or more required
if (IsEmpty(value))
{ throw new ArgumentException("A sequence requires at least one value."); }
// Sequence: Tag 0x30 (16, Universal, Constructed)
return new AsnType(0x30, value.GetBytes());
}
示例4: CreateBitString
/// <summary>
/// An ordered sequence of zero, one or more bits. Returns
/// the AsnType representing an ASN.1 encoded bit string.
/// If value is null, an empty (0 length) bit string is
/// returned.
/// </summary>
/// <param name="value">An AsnType object to be encoded.</param>
/// <returns>Returns the AsnType representing an ASN.1
/// encoded bit string.</returns>
/// <seealso cref="CreateBitString(byte[])"/>
/// <seealso cref="CreateBitString(byte[], uint)"/>
/// <seealso cref="CreateBitString(AsnType[])"/>
/// <seealso cref="CreateBitString(String)"/>
/// <seealso cref="CreateOctetString(byte[])"/>
/// <seealso cref="CreateOctetString(AsnType)"/>
/// <seealso cref="CreateOctetString(AsnType[])"/>
/// <seealso cref="CreateOctetString(String)"/>
internal static AsnType CreateBitString(AsnType value)
{
if (IsEmpty(value))
{ return new AsnType(0x03, EMPTY); }
// BitString: Tag 0x03 (3, Universal, Primitive)
return CreateBitString(value.GetBytes(), 0x00);
}