Random r = new Random(); byte[] bytes = new byte[6]; var t = new StringBuilder(); for (int j = 0; j < 16; j++) { r.NextBytes(bytes); t.AppendLine("KeyA["+ j +"] = "" + ByteHexHelper.ByteToHex(bytes) + "";"); } for (int j = 0; j < 16; j++) { r.NextBytes(bytes); t.AppendLine("KeyB[" + j + "] = "" + ByteHexHelper.ByteToHex(bytes) + "";"); } textBox3.Text = t.ToString();