class,contains,functions,which,helpful,creati
Quick Search for:  in language:    
class,contains,functions,which,helpful,creati
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
RentACoder Stats

 Code:  lines
 Jobs: 0 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for RentACoder.
Wrapping Scrolling Text
By Paranoid_Androi d on 7/2


Create A Dummy File
By AML on 7/2


Click here to see a screenshot of this code!Captionbar manipulation!
By Peter Hebels on 7/2

(Screen Shot)

A Game Of War
By Co0nest on 7/2


Click here to see a screenshot of this code!KeyGen Example
By Bengie|NET on 7/2

(Screen Shot)

Click here to see a screenshot of this code!OpenBrowser v1.9
By Orlando Jerez on 7/2

(Screen Shot)

SendMessageBySt ring() Example
By Jaime Muscatelli on 7/2


Click here to see a screenshot of this code!FirstSunday
By Jan Paul Penning on 7/2

(Screen Shot)

Click here to see a screenshot of this code!Ikonz v1.0
By Gaurav Creations on 7/2

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

RegCodes

Print
Email
 
VB icon
Submitted on: 12/8/1998
By: Andy Carrasco 
Level: Not Given
User Rating: By 103 Users
Compatibility:

Users have accessed this code 10378 times.
 
 
     This class contains two functions which can be helpful in creating an online shareware registration system for your software projects. GenerateKeyCode takes a username, or any other string, and generates a unique human-readable registration code (such as 9397-JQM0LD0YJV from the string: Andy Carrasco). GenerateKeyCode will generate a totally unique registration code over and over again, even for the exact same name! VerifyKeyCode is the partner function, and will verify if a keycode matches a given name.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    //**************************************
    //     
    // Name: RegCodes
    // Description:This class contains two f
    //     unctions which can be helpful in creatin
    //     g an online shareware registration syste
    //     m for your software projects. GenerateKe
    //     yCode takes a username, or any other str
    //     ing, and generates a unique human-readab
    //     le registration code (such as 9397-JQM0L
    //     D0YJV from the string: Andy Carrasco). G
    //     enerateKeyCode will generate a totally u
    //     nique registration code over and over ag
    //     ain, even for the exact same name! Verif
    //     yKeyCode is the partner function, and wi
    //     ll verify if a keycode matches a given n
    //     ame.
    // By: Andy Carrasco
    //
    // Side Effects:IMPORTANT NOTE!
    Although the codes generated from this algorithm will throughly confuse, and secure your code from, the average user, I make absolutely no gaurantee of security. The average hacker is NOT the average user, and anyone with a fairly general understanding of cyphering could quickly crack these algorithms. On the other hand, there are NO registration code utilities which gaurantee security, it would be foolish to believe that any form of encryption is totally secure. You may freely, and are encouraged to, use this algorithm in your own registration utilities, provided that you fully understand that I do not gaurantee the security of these functions, and that I will take no liability for any losses occuring from your use of these functions. They are primarily intended as a learning facility. 
    Andy Carrasco
    //
    //This code is copyrighted and has    // limited warranties.Please see http://
    //     www.Planet-Source-Code.com/xq/ASP/txtCod
    //     eId.1199/lngWId.-10/qx/vb/scripts/ShowCo
    //     de.htm    //for details.    //**************************************
    //     
    
    Option Explicit
    ' Name: GenerateKeyCode
    '
    ' Description:
    'This little routine generates a keycode for shareware registration in the
    'format XXXX-YYYYYYYYYY, based on the Name given as an argument. The first
    'four digits are a randomly generated seed value, which makes 8999 possible keycodes
    'for people with the same name (like John Smith). The last four digits are
    'the actual code.
    '
    ' Written by:
    'Andy Carrasco (Copyright 1998)
    '
    Public Function GenerateKeyCode(sName As String) As String
    Dim sRandomSeed As String
    Dim sKeyCode As String
    Dim X As Long
    Dim KeyCounter As Long
    Dim PrimaryLetter As Long
    Dim CodedLetter As Long
    Dim sBuffer As String
    Randomize
    sRandomSeed = CStr(Int((9999 - 1000 + 1) * Rnd + 1000))
    sName = UCase$(sName)
    KeyCounter = 1
    'Clean up sName so there are no illegal characters.
    For X = 1 To Len(sName)
    If Asc(Mid$(sName, X, 1)) >= 65 And Asc(Mid$(sName, X, 1)) <= 90 Then sBuffer = sBuffer & Mid$(sName, X, 1)
    Next X
    sName = sBuffer
    'if the name is less than 10 characters long, pad it out with ASCII 65
    Do While Len(sName) < 10
    sName = sName + Chr$(65)
    Loop
    For X = 1 To Len(sName)
    PrimaryLetter = Asc(Mid$(sName, X, 1))
    CodedLetter = PrimaryLetter + CInt(Mid$(sRandomSeed, KeyCounter, 1))
    If CodedLetter < 90 Then
    sKeyCode = sKeyCode + Chr$(CodedLetter)
    Else
    sKeyCode = sKeyCode + "0"
    End If
    'Increment the keycounter
    KeyCounter = KeyCounter + 1
    If KeyCounter > 4 Then KeyCounter = 1
    Next X
    GenerateKeyCode = sRandomSeed + "-" + Left$(sKeyCode, 10)
    End Function
    ' Name: VerifyKeyCode
    '
    ' Description:
    'Verifies if a given keycode is valid for a given name.
    '
    ' Parameters:
    'sName- A string containing the user name to validate the key against
    'sKeyCode- A string containins the keycode in the form XXXX-YYYYYYYYYY.
    '
    Public Function VerifyKeyCode(sName As String, sKeyCode As String) As Boolean
    Dim sRandomSeed As String
    Dim X As Long
    Dim KeyCounter As Long
    Dim PrimaryLetter As Long
    Dim DecodedKey As String
    Dim AntiCodedLetter As Long
    Dim sBuffer As String
    sRandomSeed = Left$(sKeyCode, InStr(sKeyCode, "-") - 1)
    sName = UCase$(sName)
    sKeyCode = Right$(sKeyCode, 10)
    KeyCounter = 1
    'Clean up sName so there are no illegal characters.
    For X = 1 To Len(sName)
    If Asc(Mid$(sName, X, 1)) >= 65 And Asc(Mid$(sName, X, 1)) <= 90 Then sBuffer = sBuffer & Mid$(sName, X, 1)
    Next X
    sName = sBuffer
    'if the name is less than 10 characters long, pad it out with ASCII 65
    Do While Len(sName) < 10
    sName = sName + Chr$(65)
    Loop
    'now, decode the keycode
    For X = 1 To Len(sKeyCode)
    PrimaryLetter = Asc(Mid$(sKeyCode, X, 1))
    AntiCodedLetter = PrimaryLetter - CInt(Mid$(sRandomSeed, KeyCounter, 1))
    If PrimaryLetter = 48 Then 'zero
    DecodedKey = DecodedKey + Mid$(sName, X, 1) 'Take the corresponding letter from the name
    Else
    DecodedKey = DecodedKey + Chr$(AntiCodedLetter)
    End If
    'Increment the keycounter
    KeyCounter = KeyCounter + 1
    If KeyCounter > 4 Then KeyCounter = 1
    Next X
    If DecodedKey = Left$(sName, 10) Then
    VerifyKeyCode = True
    Else
    VerifyKeyCode = False
    End If
    End Function


Other 2 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
4/28/1999 5:45:00 PM:Jim Sines
How do i call this function? 
Ps I am 
a beginner
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/10/1999 3:45:00 AM:Lewis Cornick
To call these functions you would use 
the following:
dim sKey as 
string
sKey = GenerateKeyCode("Lewis 
Cornick")
'sKey would then hold the 
registration key
'To decode you 
would use this call
Dim bCorrectCode 
as Boolean
bCorrectCode = 
VerifyKeyCode("Lewis Cornick", "A 
KEYCODE")
'Where A KEYCODE is a valid 
key generated using the GenerateKeyCode 
function.
'This call would return 
TRUE if success or FALSE if an invalid 
keycode was entered.
HTH
Lewis 
Cornick
VB Add-Ins here 
@
www.geocities.com/SiliconValley/Haven
/1768
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/10/1999 5:40:00 AM:Andy Carrasco
Hrm... Perhaps I should have written 
better instructions for the new VBers 
out there. Thanks Mr. Cornick for 
posting that information for me! 
;)
Andy Carrasco
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/31/1999 1:33:00 AM:Jonathan Feucht
Sounds interesting. I send all my 
programs here, anyway.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/10/1999 7:55:00 AM:Groone
This is great code but there is one 
problem.  On the verifyKeyCode 
function, if you give a name...any 
name
and 0000-0000000000 as a keycode, 
the return will always be 
true
bCorrectCode = 
VerifyKeyCode("Lewis Cornick", 
"0000-0000000000")
bCorrectCode = 
true
Let me know when and if you get 
this corrected.  Thanks!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/12/1999 9:51:00 AM:Jason Monroe
There is a rather simple fix for this.. 
 In the VerifyKeyCode routine, the 
first thing you do is check and see if 
your key is = to all zero's.  If it is, 
then return false and call it a day.  
Presto changeo, back door is plugged.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/11/1999 9:30:00 AM:Andy Carrasco
Excellent fix Jason, I didn't realize 
that would happen, but we can't see 
every possibility can we? Thanks a 
lot!
Andy Carrasco
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/6/1999 6:33:00 PM:Phrostbyte Software
I found a bug
The code needs to be 
numerical or the program crashes, like 
if someone types "hi" for the serial 
number the program crashes
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/3/2000 2:59:26 PM:Rick
Thanks a lot Lewis.  This helps a lot.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/3/2000 9:31:13 PM:hiro
HI, 
how many conbinations of the 
serial number
can it produce ?
Is 
there possible way to generate
tons of 
serial numbers ?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/29/2000 4:01:20 PM:Bobbis
Hey buddy try this keycode for every 
namexxxx-0000000000the xxxx can be 
anythingtry also 0000000000 only...this 
is good work but... not totally secure
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/29/2000 4:01:24 PM:Bobbis
Hey buddy try this keycode for every 
name
xxxx-0000000000
the xxxx can be 
anything
try also 0000000000 
only...
this is good work but... not 
totally secure
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/21/2002 3:13:29 AM:James Kelly Jr.
AWSOME! Just what im looking for. Thnx 
a bunch!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | RentACoder Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.