/// <summary> /// Constructor /// </summary> public Cypher(string str, byte[] sign = null, string cryptoAlgorithm = "", string signAlgorithm = "") { this.TrigintaHexValue = TrigintaHex.Parse(str); this.Sign = sign; this.CryptoAlgorithm = cryptoAlgorithm; this.SignAlgorithm = signAlgorithm; }
public void Deserialize(string xmlStr) { try { string cypherStr = null; string signStr = null; XmlTextReader xmlReader = new XmlTextReader(new System.IO.StringReader(xmlStr)); string pivotElement = null; while (xmlReader.Read()) { switch (xmlReader.NodeType) { case XmlNodeType.Element: { pivotElement = xmlReader.Name; } break; case XmlNodeType.Text: { if (pivotElement == "cypher") { cypherStr = xmlReader.Value; } else if (pivotElement == "sign") { signStr = xmlReader.Value; } } break; } } byte[] sign = null; if (!string.IsNullOrEmpty(signStr)) { sign = new BigInteger(signStr, 16).getBytes(); } Cypher cypher = new Cypher(new BigInteger(TrigintaHex.Parse(cypherStr).Value), sign); this.TrigintaHexValue = cypher.TrigintaHexValue; this.Sign = cypher.Sign; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }