Hi Ron.
The hardest part of your request is getting back to the original. I would suggest using Cipher (File #
9222) to encrypt the string and store it off somewhere and then generate a checksum using SYS(2007) which you can then generate a key from. Checksum is not unique but probably good enough for what you want. Here's some code that I adapted from a message by Cetin Basoz (Message #
510221) that takes the string and creates a 20 character key -
SET LIBRARY TO cipher50.fll
lcKey = '100967264812303132072492020405'
lcEncrypted = Encrypt(lcKey, "Password")
lcCRC = padl(val(sys(2007,lcEncrypted)),5,'0')
lcKey = ''
for ix=1 to 5
lcKey = lcKey + padl(ToBase36(val(substr(lcCRC,ix,1))^5),4,'0')
endfor
? lcKey
function ToBase36
lparameters tnNumber
local lnNumber
lcStr=''
do while tnNumber >= 36
lnNumber = tnNumber % 36
lcStr = iif(lnNumber<10, str(lnNumber,1), chr(asc('A')-10+lnNumber))+lcStr
tnNumber = int(tnNumber / 36)
enddo
lcStr = iif(tnNumber<10, str(tnNumber,1), chr(asc('A')-10+tnNumber))+lcStr
return lcStr
Hope this at least gives you start. This is untested code.
Dan
>I am looking for a way to generate a product key.
>
>I will be using a 30 digit number that is unique to an application and I need to generate a 10 to 20 digit key for it.
>
>What would be the best way to do this?
>
>TIA Ron