Beginner | object | encrypt | solve | Problem my password encryption method:
First write an encryption function encrypt (str):
<%
function Encrypt (str)
Dim I,c,length,texts,seed
length = Len (str)
Texts = ""
For i = 1 to length
c = Mid (Str,i,length)
SEED=ASC (c)
If seed >asc ("hh") then//
SEED=SEED-15//Prevent overflow problems
End If//
Seed=i+length+seed
Texts = texts & Chr (SEED)
Next
Texts = texts & Mid (Str,length,length)
Encrypt =texts
End Function
%>
The VBScript function used above:
Len (str) returns the number of characters in a string
ASC () returns the ANSI character code for the first letter of each string
The CHR () function returns the character corresponding to the specified character code
Mid (Str,i,length) returns the length characters from the first character in the string str
Another input password that link, with JS control can only input
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
and limit the length of the grumble password, 12 should be OK
Implementation functions
function Charsinbag (s, bag)
{
var i;
for (i = 0; i < s.length; i++)
{
var c = S.charat (i); Extract characters from a string
if (Bag.indexof (c) = =-1) return false;
}
return true;
}
Before you write the data:
Password =encrypt (Request ("password"))
Password =replace (password, "'", "") to prevent terrible '
Effect
Password: 1111
Password after encryption: 789:;1
Password: 00zzzzzzzz
Password after encryption: <xyz{|} ~z
It's so simple ^ ^
Algorithm can be changed according to their own preferences