asp.net生成6位随机码
.net的6位随机码代码
c#代码
<%@ page language="c#" %>
<%
//----------------------- 随机密码开始 ---------------------------
arraylist myarray = new arraylist();
random random = new random();
string str = null;
//循环的次数
int nums = 6;
while (nums > 0)
{
int i = random.next(1, 9);
// if (!myarray.contains(i))
// {
if (myarray.count < 6)
{
myarray.add(i);
}
// }
nums -= 1;
}
for (int j = 0; j <= myarray.count - 1; j++)
{
str += myarray[j].tostring();
}
//----------------------- 随机密码结束 ---------------------------
response.write(str + " my array count --> " + myarray.count);
%>
<%@ page language="c#" %>
<%
//----------------------- 随机密码开始 ---------------------------
arraylist myarray = new arraylist();
random random = new random();
string str = null;
//循环的次数
int nums = 6;
while (nums > 0)
{
int i = random.next(1, 9);
// if (!myarray.contains(i))
// {
if (myarray.count < 6)
{
myarray.add(i);
}
// }
nums -= 1;
}
for (int j = 0; j <= myarray.count - 1; j++)
{
str += myarray[j].tostring();
}
//----------------------- 随机密码结束 ---------------------------
response.write(str + " my array count --> " + myarray.count);
%>
asp的6位随机数字的代码
asp代码
<%
'----------------------- 随机密码开始 ---------------------------
randomize
freemember=int((999999 * rnd) + 1) '方法1
function makepassword(maxlen) '方法2,生成的随机码包含字母
dim strnewpass
dim whatsnext, upper, lower, intcounter
randomize
for intcounter = 1 to maxlen
whatsnext = int((1 - 0 + 1) * rnd + 0)
if whatsnext = 0 then
'character
upper = 90
lower = 65
else
upper = 57
lower = 48
end if
strnewpass = strnewpass & chr(int((upper - lower + 1) * rnd + lower))
next
makepassword = strnewpass
end function
' freemember = makepassword(6)
'----------------------- 随机密码结束 ---------------------------
freemember = int((999999-100000+1)*rnd+100000)'方法3
response.write freemember & " my array count --> " &len(freemember)
%>
摘自 chenliang1234576
上一篇: 集成AndFix热修复
下一篇: 三国平局大师是谁?不是赵云或张飞