public static string ToHex(byte[] array) { var hex = new StringBuilder(array.Length * 2); foreach (byte b in array) { hex.AppendFormat("{0:x2}", b); } return hex.ToString(); }