函式一
<%
function makepassword(byval maxlen)
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
%>
makepassword(str) ''str 密碼的位數
函式二<% function gen_key(digits)
dim char_array(35)
char_array(0) = "0"
char_array(1) = "1"
char_array(2) = "2"
char_array(3) = "3"
char_array(4) = "4"
char_array(5) = "5"
char_array(6) = "6"
char_array(7) = "7"
char_array(8) = "8"
char_array(9) = "9"
char_array(10) = "a"
char_array(11) = "b"
char_array(12) = "c"
char_array(13) = "d"
char_array(14) = "e"
char_array(15) = "f"
char_array(16) = "g"
char_array(17) = "h"
char_array(18) = "i"
char_array(19) = "j"
char_array(20) = "k"
char_array(21) = "l"
char_array(22) = "m"
char_array(23) = "n"
char_array(24) = "o"
char_array(25) = "p"
char_array(26) = "q"
char_array(27) = "r"
char_array(28) = "s"
char_array(29) = "t"
char_array(30) = "u"
char_array(31) = "v"
char_array(32) = "w"
char_array(33) = "x"
char_array(34) = "y"
char_array(35) = "z"
randomize
do while len(output) < digits
num = char_array(int(35 * rnd + 0))
output = output + num
loop
gen_key = output
end function
%>
gen_key(str) ''str為密碼位數
這個函式還可以擴充套件。。如果你還要加上「大小寫敏感區分大小寫」特性的話,修改陣列大小為char_array(50),然後在後面列出所有可能的小寫字元。例如:
char_array(36) = "a"
char_array(37) = "b"
...............類推
ASP生成隨機密碼
asp生成隨機密碼的兩個函式 函式一 function makepassword byval maxlen dim strnewpass dim whatsnext,upper,lower,intcounter randomize for intcounter 1 to maxlen whatsne...
純數字隨機密碼生成函式
做一些小系統,經常要初始化使用者密碼,密碼要隨機,但又不能太複雜。特別像一些不重要的系統,比如,投票 等等。下面就是我寫的純數字隨機密碼生成函式 create or replace function public.isnumeric text returns boolean language sql...
shell生成乙個隨機密碼
linux作業系統的一大優點是對於同樣一件事情,你可以使用高達數百種方法來實現它。例如,你可以通過數十種方法來生成隨機密碼。本文將介紹生成隨機密碼的十種方法。這些方法均收集於command line fu,並且在我們自己的linux pc機上測試過。這十種方法的一些在安裝了cygwin的window...