'**************************************************************** ' Declarations and initialisations ' Note this assumes that you have validated the form client-side. Dim strBookID, strUserName, strBookTitle, strSecretEdit, strRegKey strSecretEdit = "xxxxxxxxxxxx" ' this is unique to your version - do not edit 'Collect form inputs and ensure that they are all 12 characters long strBookID = Trim(Request.Form("INCLUDEID")) & "123" strUserName = Trim(Request.Form("USERNAME")) & Space(9) strBookTitle = Trim(Request.Form("INCLUDETITLE")) & Space(9) '**************************************************************** 'This section provides the execution control Call GenRegKey ' At this point in the code you could put calls ' to other routines, such as... ' update an order, update a log file, send an e-mail '****************************************************************** 'This is the procedure that generates the registration key Sub GenRegKey Dim ascInStrBookID, ascInStrUserName, ascInStrBookTitle, ascInStrSecretEdit 'variables that hold the individual characters in the strings. Dim idx3, idx4 'used as index variables to control loops and move through strings a character at a time. Dim ascKeyChar1, ascKeyChar2 ' used to store the ascii value of characters in strings Dim strName, intAdd 'this is the integer that is added later 'For each of the 12 letters in the input strings For idx3 = 1 to 12 if strBookID = "123" Then ascInStrBookID = 1 Else ascInStrBookID = Asc(Mid(strBookID,idx3,1)) End If ascInStrUserName = Asc(Mid(strUserName,idx3,1)) ascInStrBookTitle = Asc(Mid(strBookTitle,idx3,1)) ascInStrSecretEdit = Asc(Mid(strSecretEdit,idx3,1)) ascKeyChar1 = ascInStrUserName XOR ascInStrBookTitle XOR ascInStrSecretEdit XOR ascInStrBookID if ascKeyChar1 = 0 Then ascKeyChar1 = 255 End If strName = strName & chr(ascKeyChar1) Next For idx4 = 1 to 12 Select Case idx4 Case 1 intAdd = 6 Case 2 intAdd = 14 Case 3 intAdd = 9 Case 4 intAdd = 15 Case 5 intAdd = 3 Case 6 intAdd = 5 Case 7 intAdd = 1 Case 8 intAdd = 18 Case 9 intAdd = 13 Case 10 intAdd = 8 Case 11 intAdd = 12 Case 12 intAdd = 19 End Select ascKeyChar2 = asc(Mid(strName,idx4,1)) + intAdd Do until ascKeyChar2 < 91 ascKeyChar2 = (ascKeyChar2-25) Loop Do until ascKeyChar2 > 64 ascKeyChar2 = (ascKeyChar2+25) Loop strRegKey = strRegKey & chr(ascKeyChar2) Next End Sub