Sample serial number validator for a shareware app.
OS version: Any
(*
WARNING! THIS IS SIMPLE SAMPLE CODE FOR A S/N VALIDATOR
This is the most typical method to protect a shareware application.
The user download the full application, and it can be easily
registered after purchase: no need to download a "full retail" version,
etc, etc, etc.
Usually, you provide to the "validateSN" two values: user's mail and
serial number. If you sell on-line your app, you know your user's mail,
which is a "unique" string in the world. Then, you generate the matching
serial number and send him back.
Typical serial numbers are *numbers*, *strings* or a mix of them:
341972236
mohgvuicfk
APP103-6456-1737-2358
Please, customize this handler as much as you wish. Include a copy like
this in your app, and keep yours one simply to generate the SN,
given "key1" (your user's mail address).
Also, you must know that AppleScript stores handler and variable names
as plain-ascii, so you better choose a strange name for your handlers
and variables in these routines, such as "|\||" or "a".
*)
validateSN("happybirthd@y.net", "APP-531758889") --> true
to validateSN(key1, key2)
local finalCode
set userMail to key1 --> assume this is a mail address
set userCode to key2 --> this is the code you provided your user
--> use any algorithm, complex-ize as much as you wish
--> get 3 known variables to generate the code
set var1 to offset of "@" in userMail
set var2 to offset of "." in userMail
set var3 to userMail's length
set finalCode to var1 * var2 * var3
--> do something with the input data
set userMail to reverse of (userMail's text items)
set userMailLength to userMail's length
repeat with i from 1 to userMailLength
set finalCode to finalCode + (ASCII number userMail's item i) * i
end repeat
set finalCode to round (finalCode * var1 * var2 * var3 * (pi ^ 2))
--> uncomment the following for your own use (guess s/n)
-- return "APP-" & finalCode
if "A" & "P" & "P" & "-" & finalCode = userCode then
return true
else
return false
end if
end validateSN