Product Key

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to produce a product key based upon the Product name, a purchase date
and one or two other fields, that is provided to the user to register their
database. I have code for encryting passwords but that produces a lot of
characters that are not keyable. I need to find an algorithm that restricts
the coded information to alphanumeric.

Does anyone have any examples of this.
 
Here are two functions that I often use as a "group" for these types of
purposes. Just list all the characters that are valid in the Select Case
part of the second function:



Public Function GetARandomCharacter() As String
Dim xlngAsciiNum As Long

On Error Resume Next

Randomize
Do
xlngAsciiNum = Int((256 * Rnd) + 1)
If IsAValidRandomCharacter(xlngAsciiNum) = True Then
GetARandomCharacter = Chr(xlngAsciiNum)
Exit Do
End If
Loop

Exit Function
End Function


Private Function IsAValidRandomCharacter(xlngAsciiNumber As Long) As Boolean
On Error Resume Next

Select Case xlngAsciiNumber

Case Asc("a") To Asc("z"), Asc("A") To Asc("Z"), _
Asc("0") To Asc("9")

IsAValidCharacter = True


Case Else
IsAValidCharacter = False

End Select
Exit Function
End Function
 
Thanks for you reply.

I have looked at the code below and I can't quite work out from the example
how I would use it to translate a string into a key. The same string has to
be translated into the same key each time, possibly with the use of a coding
string or number.
 
The functions won't do creation and translation of a specific key; you'd
need to write other programming to do that. I posted these functions in
response to my understanding that you were asking how to limit the randomly
chosen characters to a specific set of characters.
 
OK. You have missunderstood the problem. The characters are not random and
must produce the same result every time, otherwise you can never validate
them. The routines that I have can both produce an encrypted string, and
then decrypt that result to give the original input. While I don't
necessarily have to be able to decrypt this result, I will have to be able to
reproduce it to validate the user entered key.
 
Sorry, I am unable to help you with this issue. Perhaps another person can
give you some assistance.
--

Ken Snell
<MS ACCESS MVP>
 
Back
Top