ASP.NET?е????????????
???????????? ???????[ 2016/6/1 10:31:00 ] ??????????????????? .NET
????????????:
??????.NET?е? Sytem.Guid.NewGuid().ToString() ????????????????128bit???????????????.
??????????????0-9??a-z???????????????????“-”??????.
????string strNewPW = System.Guid.NewGuid().ToString();
??????????????:7f44aed7-f8a4-4229-b64a-6a3e50d920e0
??????????£???????е?“-”???????μ?????32??????????????????????????????????????????????????.
???????8λ:
????string strNewPW = System.Guid.NewGuid().ToString().Replace("-"?? "").Substring(0?? 8);
????????:7f44aed7
????or (?????)
????string strNewPW =Guid.NewGuid().ToString("n")
????????????:
????????????
protected void Page_Load(object sender?? EventArgs e)
{
//?趨?????Χ?:??Сд??????????????????.
string strPwChar = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//????????8.
string strNewPW = MakePassword(strPwChar?? 8);
Response.Write(strNewPW);
}
/// <summary>
/// ????????????
/// </summary>
/// <param name="strPwChar">??????????????????????????Щ???</param>
/// <param name="intlen">??????????????????????</param>
public 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;
}
????????:Qk8JW61c
???????? MakePassword ??????????????strPwChar????????????????????????????Щ?????intlen???????????????????????????????????????????? Random ??? Next() ????????????????????? 0 ??С?? intlen ???????????????????????????????????????????????????????????????????????????????????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11