public static string GetRandomKey(int length) { string ret = string.Empty; int i = length; while ((i--) > 0) { Random rd = new Random(); ret = ret + MiddleWare.intToHexString(rd.Next(1, 255)); } return(ret); }
public static string DecToHex(int n) { string hex = string.Empty; if (n < 256) { string str = "0" + MiddleWare.intToHexString(n); return(str.Substring(str.Length - 2)); } if (n >= 256) { string str = "0" + MiddleWare.intToHexString(n); hex = str.Substring(str.Length - 4); return(hex.Substring(0, 2) + " " + hex.Substring(hex.Length - 2)); } return(string.Empty); }