}
/// <summary> /// 获取时间戳 /// </summary> /// <returns></returns> private string GetTimeStamp() { TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); return Convert.ToInt32(ts.TotalSeconds).ToString(); } /// <summary> /// 生成随机字符串 /// </summary> /// <param name="strPwChar">传入生成的随机字符串可以使用哪些字符</param> /// <param name="intlen">传入生成的随机字符串的长度</param> private static string MakePassWord(string strPwChar, int intlen) { string strRe = ""; int iRandNum; Random rnd = new Random(); for (int i = 0; i < intlen; i++) { iRandNum = rnd.Next(strPwChar.Length); strRe += strPwChar[iRandNum]; } return strRe; } /// <summary> /// 获取随机字符串 /// </summary> /// <returns></returns> private string GetNonce() { //设定字符范围为:大小写字母及数字的随机字符串. string strPwChar = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //截取长度为20 string strNewPW = MakePassword(strPwChar,20); return strNewPW; }
新闻热点
疑难解答