/// <summary> /// Load ASN.1 encoded data from Stream. /// </summary> /// <param name="stream">Stream data.</param> public void LoadData(Stream stream) { stream.Position = 0; if (!rootNode.LoadData(stream)) { throw new Exception("Failed to load data."); } rawData = new byte[stream.Length]; stream.Position = 0; stream.Read(rawData, 0, rawData.Length); }
/// <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); }