admin
05-30-2003, 01:32 PM
First of all, this script will encrypt a text string, but you'll have to figure out how to un-encrypt it :) If nothing else, you'll see how several built-in functions are used ( Len(), Randomize, Mid(), MOD, Asc(), Int(), and Rnd() ).
This assumes a form with a field named Password...
<%
legalChars = "ABCDEFGHIJKLMNPQRSTUVWXYZ123456789"
legalLen = Len(legalChars)
' grab the value entered into the form
xtext = Request.Form("Password")
If Len(xtext) = 0 Then
makePW = "Value not given"
Else
Randomize
For cn = 1 To 6
ch = Mid(xtext, ((cn + 3) MOD Len(xtext)) + 1, 1)
For dummy = 1 To Asc(ch)
n = Rnd(1)
Next
cnum = 1 + Int(legalLen * Rnd(1))
pw = pw & Mid(legalChars, cnum, 1)
Next
makePW = pw
End If
response.write "<br>Password = " & makePW
%>
This assumes a form with a field named Password...
<%
legalChars = "ABCDEFGHIJKLMNPQRSTUVWXYZ123456789"
legalLen = Len(legalChars)
' grab the value entered into the form
xtext = Request.Form("Password")
If Len(xtext) = 0 Then
makePW = "Value not given"
Else
Randomize
For cn = 1 To 6
ch = Mid(xtext, ((cn + 3) MOD Len(xtext)) + 1, 1)
For dummy = 1 To Asc(ch)
n = Rnd(1)
Next
cnum = 1 + Int(legalLen * Rnd(1))
pw = pw & Mid(legalChars, cnum, 1)
Next
makePW = pw
End If
response.write "<br>Password = " & makePW
%>