Пример #1
0
        /// <summary>
        /// Clone a new Asn1Node by current node.
        /// </summary>
        /// <returns>new node.</returns>
        public Asn1Node Clone()
        {
            MemoryStream ms = new MemoryStream();

            this.SaveData(ms);
            ms.Position = 0;
            Asn1Node node = new Asn1Node();

            node.LoadData(ms);
            return(node);
        }
Пример #2
0
        /// <summary>
        /// Check if the string is ASN.1 encoded hex string.
        /// </summary>
        /// <param name="dataStr">The string.</param>
        /// <returns>true:Yes, false:No.</returns>
        public static bool IsAsn1EncodedHexStr(string dataStr)
        {
            bool retval = false;

            try
            {
                byte[] data = HexStrToBytes(dataStr);
                if (data.Length > 0)
                {
                    Asn1Node node = new Asn1Node();
                    retval = node.LoadData(data);
                }
            }
            catch
            {
                retval = false;
            }
            return(retval);
        }