public static string CreateCommand(string signature, string input, IKeySym privateKey) { IParser <ParamArgs> parser = new CommandParser(); ParamArgs output = parser.Parse(input); if (output.Count == 0) { throw new OperationCanceledException("Could not parse command."); } Header header = new Header(signature, "", output.Get <string>("Command")); string jsonHeader = Newtonsoft.Json.JsonConvert.SerializeObject(header); DynamicData detail = new DynamicData(); foreach (string key in output.ToDictionary().Keys) { if (!key.Equals("Command")) { detail.Add(key, output.Get <object>(key)); } } string jsonDetail = Newtonsoft.Json.JsonConvert.SerializeObject(detail.GetDictionary()); Crypter crypter = new Crypter(privateKey); string final = string.Format(Format, jsonHeader, jsonDetail); return(crypter.Encrypt(final)); }
public Crypter(IKeySym keySym) { if (keySym == null) { throw new ArgumentNullException("\'KeySym\' cannot be null."); } privateKey = keySym; }
public Client(string ip, int port, IKeySym privateKey) { this.ip = ip; this.port = port; if (privateKey == null) { throw new ArgumentNullException("privateKey"); } this.privateKey = privateKey; tcpClient = new TcpClient(); crypter = new Crypter(privateKey); encode = Encoding.GetEncoding("ibm850"); parser = new CommandParser(); }
public static string CreateCommand(string signature, string input, IKeySym privateKey) { IParser<ParamArgs> parser = new CommandParser(); ParamArgs output = parser.Parse(input); if (output.Count == 0) throw new OperationCanceledException("Could not parse command."); Header header = new Header(signature, "", output.Get<string>("Command")); string jsonHeader = Newtonsoft.Json.JsonConvert.SerializeObject(header); DynamicData detail = new DynamicData(); foreach (string key in output.ToDictionary().Keys) { if (!key.Equals("Command")) { detail.Add(key, output.Get<object>(key)); } } string jsonDetail = Newtonsoft.Json.JsonConvert.SerializeObject(detail.GetDictionary()); Crypter crypter = new Crypter(privateKey); string final = string.Format(Format, jsonHeader, jsonDetail); return crypter.Encrypt(final); }
public TcpCommand(string hostName, int port, IKeySym publicKey) : base(new TcpConnection(hostName, port)) { encoding = Encoding.GetEncoding("ibm850"); base.PublicKey = publicKey; }
public TcpCommand(IGSMConnection connection, IKeySym publicKey) : base(connection) { encoding = Encoding.GetEncoding("ibm850"); base.PublicKey = publicKey; }
public Crypter(IKeySym keySym) { if (keySym == null) throw new ArgumentNullException("\'KeySym\' cannot be null."); privateKey = keySym; }