Randomly generate an N-digit password composed of numbers and letters. The asp random number copy code is as follows:
<%
Randomize
Do While Len(pass)<12 'Random password digits
num1=CStr(Chr((57-48)*rnd+48)) '0~9
num2=CStr(Chr((90-65)*rnd+65)) 'A~Z
num3=CStr(Chr((122-97)*rnd+97)) 'a~z
pass=pass&num1&num2&num3
loop
%>
<%=pass%>
1. The function of the less than sign is actually the function of the small equal sign.
2. The book says that the formula for generating random numbers within a certain range is
(<upper limit>-<lower limit>+1)*rnd+<lower limit>
But the actual running result is: lower limit - upper limit + 1
(<upper limit>-<lower limit>)*rnd+<lower limit> is correct
3. Generate random passwords in groups of 3 digits. The first digit is a number, the second digit is an uppercase letter, and the third digit is a lowercase letter. Can any expert tell me how to make the position of the random number random?
Copy the code code as follows:
<%
sub sjs(n)
randomize
response.write int(rnd*n)
end sub
'n is the maximum value of the random number
%>