ASP function library (all functions can be called directly, which is very convenient) 7

Source: Internet
Author: User

'*************************************** ***********
'Function ID: 0041 [generate a random password]
'Function name: makerndpass
'Usage: generate a random password
'Parameter: passlen ---- length of the password to be generated
'Parameter: passtype ---- password type to be generated
'Return value: Verify the generated Random Password
'Type explanation:
'Passfull (available characters such as "90! @ # $ % ")
'Passnumber (pure number)
'Passspecial (uncommon characters)
'Passcharnumber (all letters and numbers)
'Passuppercharnumber (uppercase letters and numbers)
'Passlowercharnumber (lowercase letters and numbers)
'Passchar (all uppercase and lowercase letters)
'Passupperchar (all uppercase letters)
'Passlowerchar (all lowercase letters)
'Example: makerndpass (4, "passuppercharnumber ")
'*************************************** ***********
Public Function makerndpass (byval passlen, byval passtype)
Dim passfull, passnumber, passspecial, passcharnumber, passchar, pass, passuppercharnumber, passlowercharnumber, passupperchar, passlowerchar, II, jj
Passfull = "1234567890! @ # $ % ^ & * () []; ',./{}:? '~ -=\_ + | Abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"
Passnumbers = "1234567890"
Passspecial = "! @ # $ % ^ & * () []; ',./{}:? '~ -= \ _ + |"
Passcharnumber = "abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz"
Passuppercharnumber = "1234567890 abcdefghijklmnopqrstuvwxyz"
Passlowercharnumber = "abcdefghijklmnopqrstuvwxyz1234567890"
Passchar = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"
Passupperchar = "abcdefghijklmnopqrstuvwxyz"
Passlowerchar = "abcdefghijklmnopqrstuvwxyz"
Select case lcase (TRIM (passtype ))
Case "passfull"
Pass = passfull
Case "passnumber"
Pass = passnumber
Case "passspecial"
Pass = passspecial
Case "passcharnumber"
Pass = passcharnumber
Case "passchar"
Pass = passchar
Case "passupperchar"
Pass = passupperchar
Case "passlowerchar"
Pass = passlowerchar
Case "passuppercharnumber"
Pass = passuppercharnumber
Case "passlowercharnumber"
Pass = passlowercharnumber
Case else
Pass = passlowercharnumber
End select
Makerndpass = ""
For II = 1 to CINT (passlen)
Randomize
JJ = int (RND () * Len (PASS) + 1)
Makerndpass = CSTR (makerndpass) & Mid (Pass, JJ, 1)
Next
End Function
'*************************************** ***********
'Function ID: 0042 [character encryption and decryption]
'Function name: addmw
'For use: character encryption and decryption
'Parameter: nyw ---- encrypted character
'Return value: Encrypted characters
'Example:
'*************************************** ***********
Public Function addmw (byval nyw)
Addmw = ""
On Error goto 0
On Error resume next
Rndchararray = "abcdefghijklmnopqrstuvwxyz1234567890"
Randomize
Keya = mid (rndchararray, INT (RND () * 35) + 1, 1)
Keyb = mid (rndchararray, INT (RND () * 35) + 1, 1)
Temp = ""
Newstr = ""
For I = 1 to Len (nyw)
Temp = mid (nyw, I, 1)
Blowchr = ASCB (midb (temp, 1, 1) xor asc (Keya)
Bhigchr = ASCB (midb (temp, 2, 1) xor asc (keyb)
Newstr = newstr & chrb (blowchr) & chrb (bhigchr)
Next
Blowchr = ASCB (midb (keyb, 1, 1) XOR 100
Bhigchr = ASCB (midb (keyb, 2, 1) XOR 20
Keyb = chrb (blowchr) & chrb (bhigchr)
Blowchr = ASCB (midb (Keya, 1, 1) XOR 128
Bhigchr = ASCB (midb (Keya, 2, 1) XOR 18
Keya = chrb (blowchr) & chrb (bhigchr)
Newstr = keyb & Keya & strreverse (newstr)
If err. Number = 0 then
Addmw = codecookie (newstr)
End if
On Error goto 0
End Function
'*************************************** ***********
'Function ID: 0043 [decrypt character encryption and decryption]
'Function name: exmw
'Usage: decryption character encryption and decryption
'Parameter: NMW ---- encrypted character
'Return value: decrypted encrypted characters
'Example:
'*************************************** ***********
Public Function exmw (byval NMW)
Exmw = ""
On Error goto 0
On Error resume next
Dim Keya, keyb, newstr, temp
NMW = decodecookie (NMW)
Keya = mid (NMW, 2, 1)
Keyb = mid (NMW, 1, 1)
Blowchr = chrb (ASCB (midb (Keya, 1, 1) XOR 128)
Bhigchr = chrb (ASCB (midb (Keya, 2, 1) XOR 18)
Keya = blowchr & bhigchr
Blowchr = chrb (ASCB (midb (keyb, 1, 1) XOR 100)
Bhigchr = chrb (ASCB (midb (keyb, 2, 1) XOR 20)
Keyb = blowchr & bhigchr
STR = strreverse (mid (NMW, 3, Len (NMW )))
Newstr = ""
Temp = ""
For I = 1 to Len (STR)
Temp = mid (STR, I, 1)
Blowchr = ASCB (midb (temp, 1, 1) xor asc (Keya)
Bhigchr = ASCB (midb (temp, 2, 1) xor asc (keyb)
Newstr = newstr & chrb (blowchr) & chrb (bhigchr)
Next
If err. Number = 0 then
Exmw = newstr
End if
On Error goto 0
End Function
'*************************************** ***********
'Function ID: 0044 [create a data table]
'Function name: creattable
'Usage: create a data table
'Parameter: connstrs ---- database link string
'Parameter: tabnamestr ---- data table name
'Parameter: cvarrstr ---- field table (written in fname1 # type # Len # defvalue | fname1 # type # Len # defvalue |"
'Parameter: sqltype ---- SQL statement type (0 access 1 MSSQLServer)
'Fname, type, Len, defvalue Description: field name, field type, field length, default value
'Field Type C/C character T/T text I/I binary D/d Date M/M keyword (numeric type) A/A Keyword Automatic number (numeric type) n/n value (float) z/z value (INT)
'Return value: true if creation is successful, otherwise false
'Example: creattable (basicdb (3), "CS", "fa # T # | FB # C #20 # A | FC # N #5", 0)
'*************************************** ***********
Public Function creattable (byval connstrs, byval tabnamestr, byval cvarrstr, byval sqltype)
Creattable = false
On Error goto 0
On Error resume next
Dim filsarry, nefilarry, filstr, spfstr, templx, def_kh_l, def_kh_r, tempsqlstr
Def_kh_l = ""
Def_kh_r = ""
Filstr = ""
Spfstr = ""
Tempsqlstr = ""
Filsarry = Split (cvarrstr, "| ")
For AI = lbound (filsarry) to ubound (filsarry)
Nefilarry = Split (filsarry (AI ),"#")
Templx = ""
If ucase (nefilarry (1) = "C" then templx = "varchar (" & nefilarry (2 )&")"
If ucase (nefilarry (1) = "T" then templx = "text"
If ucase (nefilarry (1) = "I" then templx = "image"
If ucase (nefilarry (1) = "D" then templx = "datetime"
If ucase (nefilarry (1) = "M" then templx = "varchar (" & nefilarry (2) & ") not null primary key"
If ucase (nefilarry (1) = "A" then templx = "int identity (1, 1) not null primary key"
If ucase (nefilarry (1) = "N" then templx = "float"
If ucase (nefilarry (1) = "Z" then templx = "int"
If sqltype = 1 then
Def_kh_l = "('"
Def_kh_r = "')"
End if
If trim (nefilarry (3) <> "" Then templx = templx & "default" & def_kh_l & trim (nefilarry (3) & def_kh_r
If AI <> ubound (filsarry) then
Spfstr = spfstr & "[" & nefilarry (0) & "]" & templx &","
Else
Spfstr = spfstr & "[" & nefilarry (0) & "]" & templx
End if
Next
Tempsqlstr = "create table [" & trim (tabnamestr) & "] (" & spfstr &")"
Set fu_conn = server. Createobject ("ADODB. Connection ")
Fu_conn.open connstrs
Fu_conn.execute tempsqlstr
Fu_conn.close
Set fu_conn = nothing
If err. Number = 0 then
Creattable = true
End if
On Error goto 0
End Function
'*************************************** ***********

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.