>Hi
>
>I am developing a small package for local market in foxpro 2.6 for DOS and I want to build the registration facility in my package. So I will come to know
>how many guys are using my package.
>
>It should be like when they give Company's name in the registration screen it
>should also ask for the activation key which (when the user contacts me) they
>will enter after asking me. activation key should depend on Company's Name.
>I have written a small prog. which generates a unique key. Rightnow I am able
>to genrate only 8 character long activation key. I want to make this key long
>like other standard product.
>
>Can anyone help me in this regard ?
>
>Thanks in Advance
>
>Ashish
Ashish,
You could make a key as long as you want based on a string, random generated values etc. ie:
lcCompany='My Lovely Company Name'
lcCRC = padl(val(sys(2007,lcCompany)),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
Here a string's CRC value is extended to 4 chars per digit ending in 20 chars key. This is in a sense one way coding. You can't (you can but accept can't) get back lcCompany but you can compare the CRC value with the decoded value.
Cetin