Re: Product Key

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.

--

Ken Snell
<MS ACCESS MVP>


"Axis" <Axis@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5C8F8982-0D47-47B1-B13D-982FDC33AA6E@xxxxxxxxxxxxxxxx
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.


"Ken Snell (MVP)" wrote:

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



--

Ken Snell
<MS ACCESS MVP>


"Axis" <Axis@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E3A80061-3930-4261-AC59-B399816F181F@xxxxxxxxxxxxxxxx
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.





.



Relevant Pages

  • Re: find and remove "" character from string
    ... i have the following string s and the following code, ... remaining characters have been mapped through the given translation table, which must be a string of length 256". ... For Unicode objects, the translatemethod does not accept the ...
    (comp.lang.python)
  • Re: Using Like operator in VBA
    ... <MS ACCESS MVP> ... a left bracket [inside the bracket pair to test whether the string ... If YourVariable contains any of the wildcard characters that are used ...
    (microsoft.public.access.modulesdaovba)
  • Re: Using Like operator in VBA
    ... <MS ACCESS MVP> ... a left bracket [inside the bracket pair to test whether the string ... If YourVariable contains any of the wildcard characters that are used ...
    (microsoft.public.access.modulesdaovba)
  • Re: Micro-PEP: str.translate(None) to mean identity translation
    ... >> Bengt Richter ... characters, each and all of whose instances in the source string ... will be deleted from the source string. ... translation table, which must be a string of length 256. ...
    (comp.lang.python)
  • Re: pop up a TCHAR[1024]
    ... Send me your paycheck and I'll send you the modified code. ... null characters, that's where the ... // other than the one we added at the end above, the string will not ... // after the translation. ...
    (microsoft.public.windowsce.embedded.vc)