| 119 |
ghuddy |
1 |
<%
|
|
|
2 |
'******************************
|
|
|
3 |
' KeyGeN.asp
|
|
|
4 |
'******************************
|
|
|
5 |
|
|
|
6 |
Const g_KeyLocation = "c:\key.txt"
|
|
|
7 |
Const g_KeyLen = 512
|
|
|
8 |
|
|
|
9 |
On Error Resume Next
|
|
|
10 |
|
|
|
11 |
Call WriteKeyToFile(KeyGeN(g_KeyLen),g_KeyLocation)
|
|
|
12 |
|
|
|
13 |
if Err <> 0 Then
|
|
|
14 |
Response.Write "ERROR GENERATING KEY" & "<P>"
|
|
|
15 |
Response.Write Err.Number & "<BR>"
|
|
|
16 |
Response.Write Err.Description & "<BR>"
|
|
|
17 |
Else
|
|
|
18 |
Response.Write "KEY SUCCESSFULLY GENERATED"
|
|
|
19 |
End If
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
Sub WriteKeyToFile(MyKeyString,strFileName)
|
|
|
23 |
Dim keyFile, fso
|
|
|
24 |
set fso = Server.CreateObject("scripting.FileSystemObject")
|
|
|
25 |
set keyFile = fso.CreateTextFile(strFileName, true)
|
|
|
26 |
keyFile.WriteLine(MyKeyString)
|
|
|
27 |
keyFile.Close
|
|
|
28 |
End Sub
|
|
|
29 |
|
|
|
30 |
Function KeyGeN(iKeyLength)
|
|
|
31 |
Dim k, iCount, strMyKey
|
|
|
32 |
lowerbound = 35 ' 35
|
|
|
33 |
upperbound = 96 ' 96
|
|
|
34 |
Randomize ' Initialize random-number generator.
|
|
|
35 |
for i = 1 to iKeyLength
|
|
|
36 |
s = 255
|
|
|
37 |
k = Int(((upperbound - lowerbound) + 1) * Rnd + lowerbound)
|
|
|
38 |
strMyKey = strMyKey & Chr(k) & ""
|
|
|
39 |
next
|
|
|
40 |
strMyKey = Replace(strMyKey, "'", "|")
|
|
|
41 |
strMyKey = Replace(strMyKey, VBNewLine, "|")
|
|
|
42 |
strMyKey = Replace(strMyKey, VBTab, "|")
|
|
|
43 |
strMyKey = Replace(strMyKey, VBFormFeed, "|")
|
|
|
44 |
strMyKey = Replace(strMyKey, VBVerticalTab, "|")
|
|
|
45 |
strMyKey = Replace(strMyKey, VBNullChar, "|")
|
|
|
46 |
KeyGeN = strMyKey
|
|
|
47 |
End Function
|
|
|
48 |
%>
|
|
|
49 |
|