home *** CD-ROM | disk | FTP | other *** search
-
-
- rKey v1.2/v1.2s (c) 1990, 1991 Serious Cybernetics
- Turbo Pascal(tm) 5.5 Registration Key Unit
- by Scott Davis
-
-
- -------------------------------------------------------------------------------
-
-
- The following files should be included in RKEY12.ZIP :
-
- RKEY.DOC rKey Documentation
- RKEY.TPU rKey Unit (v1.2 Has built-in string handling)
- RKEYS.TPU rKey Unit (v1.2s Uses the StrLib Unit)
- RKSAMPLE.PAS Sample program using rKey
- RKGENKEY.PAS Sample program to generate keys for RKSAMPLE.PAS
- RKGENFIL.PAS Sample program to generate a key file for RKSAMPLE.PAS
- RKBRAND.PAS Sample program to brand RKSAMPLE.PAS with a valid key
- REGISTER.FRM Registration form/information for rKey
- APPLIST.TXT List of applications written using rKey
-
-
- -------------------------------------------------------------------------------
-
-
- rKey is a Turbo Pascal (tm) 5.5 Unit designed to allow programmers to easily
- handle registration keys in their software. All of the key encryption,
- checking and key file routines are handled in rKey, requiring little effort
- on the part of the programmer. It can allow anything from simple registration
- messages to limiting program functions if the software is not registered.
-
-
- There are two versions of rKey included here. Version 1.2 is contained in
- RKEY.TPU, which has its own built-in string handling routines. Version 1.2s
- is contained in RKEYS.TPU, which uses functions from the StrLib unit. If
- you are using the StrLib unit in your programs, you will want to use RKEYS.TPU.
- Otherwise, you should use RKEY.TPU.
-
-
- All of the sample programs use RKEY.TPU. If you have StrLib and want the
- sample programs to use RKEYS.TPU, simply change :
-
- Uses
- rKey;
-
- to
-
- Uses
- rKeyS;
-
-
- The various sample programs demonstrate the 2 methods of handling keys :
-
- Method 1 : Distribute your program (for example, RKSAMPLE.EXE) and use
- a key file generation program (like RKGENFIL.EXE), which you
- do NOT distribute, to create a key file for each user who
- registers. You then send the user the key file.
-
- Method 2 : Distribute your program (for example, RKSAMPLE.EXE) and a
- branding program (like RKBRAND.EXE). You then use a key
- generation program (like RKGENKEY.EXE), which you do NOT
- distribute, to create a a key number for each user who
- registers. You then send the user the key number, which
- he/she enters into the brand program to create a key file.
-
-
- -------------------------------------------------------------------------------
-
-
- Version Notes :
-
- 1.0/1.0s 19-October-1990 Initial release of rKey
-
- 1.1/1.1s 1-December-1990 Changed rKey to store names as they are
- entered (rather than forcing them to be
- upper case). Key creation/comparisons
- are still NOT case sensitive.
-
- Fixed bug where altered key files would
- sometimes cause a runtime error. rKey
- now handles this internally. RegError
- will be set to TRUE if key file is
- altered.
-
- 1.2/1.2s 21-January-1991 Recompiled with {$O+} to allow for use
- in programs that use overlays.
-
-
- -------------------------------------------------------------------------------
-
-
- rKey contains procedures and functions to handle registration keys in
- Turbo Pascal (tm) 5.5
-
-
- The following constants are defined in rKey :
-
- rKeyVersion = '1.2'; { contains the current version of rKey }
-
-
- The following variables are defined in rKey :
-
- OwnerCode : STRING[20];
- ProgramCode : STRING[16];
- KeyFileName : STRING[8];
- KeyFilePath : STRING[79];
- RegError : BOOLEAN;
- RegStatus : BOOLEAN;
- RegLevel : BYTE;
- RegName : STRING[36];
- RegYear : WORD;
- RegMonth : WORD;
- RegDay : WORD;
- RegKey : STRING[12];
-
-
- The following procedures and functions are defined in rKey :
-
- FUNCTION MakeKey(Name : STRING; Level : BYTE) : STRING;
- FUNCTION ValidKey(Name : STRING; Level : BYTE; Key : STRING) : BOOLEAN;
- PROCEDURE GetRegInfo;
- PROCEDURE Register(Name : STRING; Level : BYTE; Key : STRING);
-
-
- -------------------------------------------------------------------------------
-
-
- OwnerCode : STRING[20];
-
- This variable is NOT initialized by rKey and MUST be set at the start of your
- program. It is used (along with ProgramCode) to generate the registration
- keys. This variable should probably be the same for all software written by a
- single person/company. Since is it used to cause your keys to be different
- from those of other programmers who are also using rKey, the more cryptic this
- variable is, the more secure your keys will be.
-
-
- Examples :
-
- OwnerCode := 'TrendSoft, Inc.';
-
- {
- If the name of your company is 'TrendSoft, Inc.', this is probably NOT a good
- OwnerCode. It would be easy for someone who knows the name of the company
- to use the rKey unit to write a program that will generate keys for your
- software.
- }
-
- OwnerCode := 'Trend&&Soft/Inc@';
-
- {
- This is better. It still uses the name of the company, but it is somewhat
- masked by the insertion of other characters and would be harder for another
- programmer to guess.
- }
-
- OwnerCode := 'Read$Make@Into';
-
- {
- This is MUCH better. It uses totally unrelated words that would be extremely
- unlikely to be used by another programmer/company.
- }
-
- OwnerCode := 'EkQW3#m,-%\uSaXo^Ej7';
-
- {
- This is most likely the best, since it uses totally random symbols.
- }
-
- IMPORTANT : You should NOT use any of the actual examples used here or in
- the sample programs included with rKey. If you do, anyone else
- who uses the same example will have IDENTICAL keys!
-
-
- -------------------------------------------------------------------------------
-
-
- ProgramCode : STRING[16];
-
- This variable is NOT initialized by rKey and MUST be set at the start of your
- program. It is used (along with OwnerCode) to generate the registration keys.
- There are several approaches to the use of ProgramCode :
-
- (1) If ProgramCode is set to the same value for several programs
- written by a person/company, keys for one piece of software will
- work on another piece of software. Using this approach, you
- could have a single key for several programs.
-
- (2) If each program has a different ProgramCode and the ProgramCode is
- not changed when the program changes, keys for one version of the
- program will work for all versions of the same program.
-
- (3) If each program has a differenct ProgramCode and the ProgramCode is
- changed when the program is changed, a different key will be
- required for each version of the program.
-
-
- Examples :
-
- ProgramCode := 'RkStuff';
-
- {
- If you wrote a program called RkSample and a program called RkUtils and
- you defined the ProgramCode as 'RkStuff' in both programs, a key for one
- program would work for the other.
- }
-
- ProgramCode := 'RkSample';
-
- {
- If you wrote a program called RkSample and a program called RkUtils and
- you defined the ProgramCode as 'RkSample' in RkSample and used a different
- ProgramCode in RkUtils, a key for one would NOT work for the other.
- }
-
- ProgramCode := 'RkSample One';
-
- {
- If you wrote a program called RkSample and you defined the ProgramCode as
- 'RkSample One' in versions 1.2, 1.2 and 1.2 and then changed the
- ProgramCode to 'RkSample Two' for version 2.0, the same key would work for
- versions 1.2, 1.2 and 1.2 but would NOT work for version 2.0.
- }
-
-
- -------------------------------------------------------------------------------
-
-
- KeyFileName : STRING[8];
-
- This variable is NOT initialized by rKey and MUST be set at the start of your
- program. It is the name of the keyfile that is read by GetRegInfo and written
- to by Register. This will probably be the name of the program file. The
- extension will be '.KEY'.
-
-
- Examples :
-
- KeyFileName := 'RKSAMPLE';
-
- {
- The key file will be 'RKSAMPLE.KEY'. Key files are always created and read
- from the same directory that the program is in. This is true even if the
- program is not in the current directory.
- }
-
-
- -------------------------------------------------------------------------------
-
-
- KeyFilePath : STRING[79];
-
- This variable is initialized by rKey to ''. GetRegInfo and Register will set
- KeyFilePath to the full directory, filename and extension of the key file. If
- no key file was found, KeyFilePath will be set to ''.
-
-
- Examples :
-
- KeyFileName := 'RKSAMPLE';
- GetRegInfo;
- IF KeyFilePath <> '' THEN
- WriteLn('Key file is ' + KeyFilePath);
-
- {
- The key file will be 'RKSAMPLE.KEY'. After GetRegInfo is called, KeyFilePath
- will contain the full pathname of the the key file, which is displayed (if it
- is not '').
- }
-
-
- -------------------------------------------------------------------------------
-
-
- RegError : BOOLEAN;
-
- This variable is initialized by rKey to FALSE. It is set by GetRegInfo and
- Register to indicate an invalid key. If RegError is TRUE after a call to
- GetRegInfo, it means that the key contained in the key file is invalid. This
- probably means that the key file has been tampered with. If RegError is set
- to TRUE after a call to Register, it means that the key that was passed to
- Register was invalid or the program was unable to create the key file; and the
- key file was NOT written.
-
-
- Examples :
-
- KeyFileName := 'RKDEMO';
- GetRegInfo;
- IF RegError THEN
- WriteLn('The KEY file has been altered!');
-
- {
- This will call GetRegInfo. If the key contained in 'RKDEMO.KEY' is invalid,
- the message 'The KEY file has been altered!' will be displayed.
- }
-
-
- -------------------------------------------------------------------------------
-
-
- RegStatus : BOOLEAN;
-
- This variable is initialized by rKey to FALSE. It is set by GetRegInfo and
- Register to indicate the software is registered. If RegStatus is TRUE then
- RegName, RegDate, RegLevel, RegYear, RegMonth and RegDay contain valid
- registration information. If RegStatus is FALSE (after a call to GetRegInfo),
- the software is unregistered.
-
-
- Examples :
-
- KeyFileName := 'RKDEMO';
- GetRegInfo;
- Write('RkDemo v1.5');
- IF RegError THEN
- WriteLn('[invalid key]')
- ELSE IF RegStatus THEN
- WriteLn('[registered]')
- ELSE
- WriteLn('[unregistered]');
-
- {
- This will call GetRegInfo. If the key contained in 'RKDEMO.KEY' is invalid,
- the message 'RkDemo v1.5 [invalid key]' will be displayed. If the program
- is registered, the message 'RkDemo v1.5 [registered]' will be displayed.
- Otherwise, the message 'RkDemo v1.5 [unregistered]' will be displayed.
- }
-
-
- -------------------------------------------------------------------------------
-
-
- RegName : BYTE;
-
- This variable is initialized by rKey to ''. It is set by GetRegInfo and
- Register if the software is registered. This variable only contains valid
- information if RegStatus is TRUE.
-
-
- Examples :
-
- KeyFileName := 'RKDEMO';
- GetRegInfo;
- Write('RkDemo v1.5');
- IF RegError THEN
- WriteLn('[invalid key]')
- ELSE IF RegStatus THEN
- WriteLn('[registered to ' + RegName + ']')
- ELSE
- WriteLn('[unregistered]');
-
- {
- This will call GetRegInfo. If the key contained in 'RKDEMO.KEY' is invalid,
- the message 'RkDemo v1.5 [invalid key]' will be displayed. If the program
- is registered, the message 'RkDemo v1.5 [registered to NAME]' will be displayed
- (with 'NAME' replaced by the name of the person that the software is
- registered to). Otherwise, the message 'RkDemo v1.5 [unregistered]' will be
- displayed.
- }
-
-
- -------------------------------------------------------------------------------
-
-
- RegLevel : BYTE;
-
- This variable is initialized by rKey to 0. It is set by GetRegInfo and
- Register if the software is registered. This variable only contains valid
- information if RegStatus is TRUE. RegLevel should always be 0, if you do not
- wish to use registration levels in your software. If registration levels are
- used, RegLevel will indicate the level at which a person is registered and
- each registration level will require a different key.
-
-
- Examples :
-
- KeyFileName := 'RKMISC';
- GetRegInfo;
- WriteLn('RkMisc v2.1 Menu');
- WriteLn;
- IF RegError THEN
- WriteLn('*** invalid registration ***')
- ELSE BEGIN
- WriteLn('[D]isplay demos');
- IF RegStatus THEN BEGIN
- WriteLn('[E]nter data');
- WriteLn('[P]rint reports');
- IF RegLevel > 0 THEN
- WriteLn('[G]raphs');
- IF RegLevel > 1 THEN
- WriteLn('[O]ther functions');
- END;
- END;
-
- {
- This will call GetRegInfo. If the key contained in 'RKMISC.KEY' is invalid,
- the message '*** invalid registration ***' will be displayed and no menu items
- will be available. If the software is unregistered, the following menu will
- be displayed :
-
- RkMisc v2.1 Menu
-
- [D]isplay demos
-
- If the software is registered at level zero (say for a $5 registration), the
- following menu would items would be available :
-
- RkMisc v2.1 Menu
-
- [D]isplay demos
- [E]nter data
- [P]rint reports
-
- If the software is registered at level one (say for a $10 registration), the
- following menu items would be available :
-
- RkMisc v2.1 Menu
-
- [D]isplay demos
- [E]nter data
- [P]rint reports
- [G]raphs
-
- If the software is registered at level two or higher (say for a $20 or more
- registration), the following menu items would be available :
-
- RkMisc v2.1 Menu
-
- [D]isplay demos
- [E]nter data
- [P]rint reports
- [G]raphs
- [O]ther functions
-
- In this way you can allow different levels of registration to allow the
- program to provide different functions, WITHOUT having distribute different
- programs for each registration level.
- }
-
-
- -------------------------------------------------------------------------------
-
-
- RegYear : WORD;
- RegMonth : WORD;
- RegDay : WORD;
-
- These variables are initialized by rKey to 0. They are set by GetRegInfo and
- Register if the software is registered. These variables only contain valid
- information if RegStatus is TRUE. These variables contain the year, month and
- day that the software was registered (when the KEY file was created).
-
-
- Examples :
-
- GetDate(cYear,cMonth,cDay,cDow); { from the Dos unit }
- KeyFileName := 'RKPROG';
- GetRegInfo;
- IF RegError THEN
- WriteLn('Error in KEY file!')
- ELSE IF RegStatus THEN BEGIN
- IF (cYear > RegYear) OR ((cYear = RegYear) AND (cMonth> RegMonth)) THEN
- WriteLn('Your 1 month evaluation key has expired. Please register.');
- END;
-
- {
- This will call GetRegInfo. If the key contained in 'RKPROG.KEY' is invalid,
- the message 'Error in KEY file!' will be displayed. If the current year is
- greater than the registration year or the year is the same and the current
- month is greater than the registration month, the following message will be
- displayed :
-
- 'Your 1 month evaluation key has expired. Please register.'
-
- The date is not used in key generation. It is simply written to the key
- file when Register is called. Therefore, the inclusion of the date was not
- intended for use in writing "crippleware" (ie: software that becomes invalid
- after a specified period of time), but rather to allow you to include an
- evaluation key with the program and display a reminder message after a
- specified period of time.
- }
-
-
- -------------------------------------------------------------------------------
-
-
- RegKey : STRING[12];
-
- This variable is initialized by rKey to '000000000000'. It is set by
- GetRegInfo and Register if the software is registered. This variable only
- contains valid information if RegStatus is TRUE. This contains the
- 12 digit hexadecimal registration key as a string.
-
-
- Examples :
-
- KeyFileName := 'RKMORE';
- GetRegInfo;
- IF RegError OR NOT RegStatus THEN BEGIN
- WriteLn('This version of RkMore is not registered.');
- WriteLn('Please read the READ.ME file for more info.');
- END ELSE
- WriteLn('This version of RkMore is registered to ' + RegName + '.');
- WriteLn('Registration key is ' + RegKey + '.');
- END;
-
- {
- This will call GetRegInfo. If the key contained in 'RKMORE.KEY' is invalid
- or the program is not registered, a message will be displayed telling the
- user how to register the program. Otherwise, the name of the person that
- that the program is registered to and the registration key will be
- displayed.
- }
-
-
- -------------------------------------------------------------------------------
-
-
- FUNCTION MakeKey(Name : STRING; Level : BYTE) : STRING;
-
- The function MakeKey will return a string containing the 12 digit hexadecimal
- registration key for Name and Level (using the pre-defined values of OwnerCode
- and ProgramCode). If you do not wish to use registration levels, simply
- pass a 0 as the Level parameter. This function is usually used to create
- registration keys or key files, in a program that is not distributed to the
- user.
-
-
- Examples :
-
- OwnerCode := 'AZ771N91P03DJSS447';
- ProgramCode := 'RkProg';
- WriteLn('Registration Key Maker for RkProg');
- WriteLn;
- WriteLn('FOR INTERNAL USE ONLY!');
- WriteLn;
- Write('Enter name : ');
- ReadLn(n);
- k := MakeKey(n,0); { registration levels are not being used }
- WriteLn;
- WriteLn('Registration key is '+k);
-
- {
- This will display a warning message and then prompt for a name. MakeKey is
- then passed the name and a 0 for the registration level. It will return the
- key in the variable k, which is then displayed.
- }
-
-
- -------------------------------------------------------------------------------
-
-
- FUNCTION ValidKey(Name : STRING; Level : BYTE; Key : STRING) : BOOLEAN;
-
- ValidKey will return TRUE, if Key is valid for Name and Level (using the
- pre-defined values of OwnerCode and ProgramCode). If you do not wish to use
- registration levels (and levels weren't used when the key was generated),
- simply pass 0 as the Level parameter. If ValidKey returns FALSE, the key is
- not valid.
-
-
- Examples :
-
- OwnerCode := 'dfk89ew32zg0imm02';
- ProgramCode := 'RkProg One';
- WriteLn('RkProg v1.3');
- WriteLn;
- Write('Enter your name : ');
- ReadLn(n);
- Write('Enter your registration key : ');
- ReadLn(k);
- IF NOT ValidKey(n,0,k) THEN BEGIN { registration levels are not used }
- WriteLn('Invalid key!');
- Halt(1);
- END;
-
- {
- This program will prompt the user to enter a name and a registration key.
- If the registration key is not valid, the program will display 'Invalid key!'
- and Halt with an errorlevel of 1.
- }
-
-
- -------------------------------------------------------------------------------
-
-
- PROCEDURE GetRegInfo;
-
- GetRegInfo will read the key file (if it exists) and set the value of the
- following variables :
-
- RegError { set to TRUE if the key file contains an invalid key }
- RegStatus { set to TRUE if the software is registered }
- RegName { set to the name of the person the software is registered to }
- RegLevel { set to the registration level (0 if not used) }
- RegYear { set to the registration year }
- RegMonth { set to the registration month }
- RegDay { set to the registration day }
- RegKey { set to the 12 digit hexadecimal registration key }
-
- GetRegInfo would generally be called near the beginning of a program (after
- OwnerCode, ProgramCode and KeyFileName are defined).
-
-
- Examples :
-
- OwnerCode := '&,<;(##@["+|~~**=#))';
- ProgramCode := 'RkTest';
- KeyFileName := 'RKTEST';
- GetRegInfo;
- IF NOT RegError THEN
- IF RegStatus THEN
- WriteLn('Registered to ' + RegName);
-
- {
- GetRegInfo will read 'RKTEST.KEY'. If it contains an invalid key, RegError
- will be set. If it doesn't exist, RegStatus will be set to FALSE. Otherwise,
- The various registration variables will be set. The program then displays
- the name of the person that the program is registered to.
- }
-
-
- -------------------------------------------------------------------------------
-
-
- PROCEDURE Register(Name : STRING; Level : BYTE; Key : STRING);
-
- Register will update the key file (creating it, if it doesn't exist) and set
- the value of the following variables :
-
- RegError { set to TRUE if the Key parameter is invalid }
- { or the file can NOT be created }
- RegStatus { set to TRUE }
- RegName { set to the Name parameter }
- RegLevel { set to the Level parameter }
- RegYear { set to the registration year }
- RegMonth { set to the registration month }
- RegDay { set to the registration day }
- RegKey { set to the Key parameter }
-
- If the Key parameter is invalid, RegError will be set to TRUE, the key file
- will NOT be written and the values of the other registration variables will
- NOT be changed. Register would generally be called by an install or branding
- program of some type. It can also be used by a key creation program, which
- is not distributed (if you want to send key files to registered users, rather
- than a key that they would enter).
-
-
- Examples :
-
- OwnerCode := 'Keyboard*Sytem=Load';
- ProgramCode := 'RkProg';
- KeyFileName := 'RKPROG';
- WriteLn('RkProg Install Program');
- WriteLn;
- Write('Enter your name : ');
- ReadLn(n);
- Write('Enter your registration key : ');
- ReadLn(k);
- Register(n,0,k); { registration level not used }
- IF RegError THEN
- WriteLn('Invalid Key. Program not installed.');
-
- {
- This program will prompt the user for a name and a registration key. Register
- will then be passed the name, 0 for the Level (which is not being used) and
- the key. If RegError is TRUE, the key was invalid and no key file was written
- (the program displays 'Invalid Key. Program not installed.'). Otherwise,
- RKPROG.KEY is written and the registration variables are set.
- }
-
-
- -------------------------------------------------------------------------------
-
-
- For more information on using rKey, see the sample Turbo Pascal (tm) programs
- that are distributed with rKey, or contact me at any of the locations listed
- below.
-
-
- -------------------------------------------------------------------------------
-
-
- rKey is shareware. You may copy and distribute RKEY11.ZIP freely, as well
- as use it for development of programs for your own use, to give away or to
- sell. All I ask is that you include all of the original files, unmodified,
- and that you do not charge for the distribution of rKey itself.
-
-
- If you like rKey and use it to develop software, a registration fee of $10
- or more toward the continued development of this unit and others like it
- would be appreciated. See REGISTER.FRM for registration information.
-
-
- Everyone registering rKey with a registration fee of $10 or more, will be
- entitled to have one piece of software (written using rKey) listed, along with
- an address or phone number, in an application list that will be included with
- all future versions of rKey. (Registration fees in excess of $10 will allow
- for additional programs to be listed.)
-
-
- There are no royalties for the distribution of programs that are written
- with rKey. A single registration fee entitles you to write and distribute
- any number of programs using rKey.
-
-
- If you have written an application using rKey, and wish to have it listed
- in the APPLIST.TXT file that is distributed with rKey, please send the
- following information via E/Mail, NetMail or US Mail :
-
- Name of Application
- Programmer's Name (optional)
- Copyright Notice
- Address or Phone Number
- System Requirements
- Cost of Program (optional)
-
-
- Questions, comments, and suggestions are welcome.
-
- Send E/Mail to Scott Davis
- Phoenix StarFighter BBS (2400 bps)
- Phone (404) 869-3410
- FidoNet Node 1:3616/20
-
- Send US Mail to Scott Davis
- Rt. 2 Box 95
- County Line Drive
- Lula, GA 30554
-
-
- -------------------------------------------------------------------------------
-
-
- I'd like to thank Danny Sosebee (Sysop of Phoenix StarFighter BBS) for
- allowing me to use his BBS as a way to receive suggestions and comments
- regarding rKey. Also, I'd like to thank Ed Ivey (Sysop of Ed's Place
- BBS - 404/532-1978 - FidoNet Node 1:3616/1) for his continued support
- and assistance in distributing my little software "projects".
-
-
- -------------------------------------------------------------------------------
-
-
- Turbo Pascal (tm) units available from Serious Cybernetics :
-
- StrLib v1.2 A Library of String Functions
- rKey v1.2/v1.2s A Unit to Handle Registration Keys
-
-
- ------------------------------------------------------------------------------
-
- rKey, StrLib (c) 1990, 1991 Serious Cybernetics
- Turbo Pascal (c) 1983, 1989 Borland International
-