// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using System.Net; using System.Net.Sockets; using System.Text; using System.Security.Cryptography; namespace E { public class Client { private static Random rng = new Random(); private static Encoding utf = new UTF8Encoding(); private static Rijndael aes = new RijndaelManaged(); private static byte[] iv = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; public static void Main(string[] args) { TcpClient cli = new TcpClient("localhost", 1234); Stream stm = new CryptoStream(cli.GetStream(), aes.CreateEncryptor(utf.GetBytes("hemmelig12345678"), iv), CryptoStreamMode.Write); int n = rng.Next(250); stm.WriteByte((byte)n); for(int i = 0; i < n; i++) { stm.WriteByte((byte)i); } stm.Close(); cli.Close(); } } }