Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Algorithms - The Basics (PART 2)


  • Please log in to reply
2 replies to this topic

#1 TcM


    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 24 November 2007 - 08:33 AM

Please Read Part 1 First:

Now, that you are satisfied with your algorithm and instructions it is time to generate results according to your algorithm, so in this case I am going to pick up random numbers and assign each one a letter, of course not B, as that will be the result.

Now let’s take these as examples:


And apply that formula on these numbers:

((((1234 + 3412 ) – 550) / 2 ) * 5 ) ^ 2 = 104857600

Now let’s not forget that for the program to accept this serial we added some instructions, the program will only take the 2nd, 3rd,4th,5th and 6th numbers, so in our case B would be 048576, if you omit the 0, still the program will not accept it! So download the program and test this, enter the following values as follows:

Posted Image

And press ‘Register’ (this will not register anything, this will just check if the values given match the algorithm!) and it should accept it! If you are too lazy to work out this algorithm yourself you are free to press the ‘Generate Key’ button and then the ‘->’ button to transfer the values from the generation part to the validation part, as follows:

Posted Image

Now if you really want to test if this really works, write purely random numbers in all 4 text boxes and it will not work!

Posted Image

So of course the more complicated and the more mathematical functions your algorithm will have the harder it will be to break! And the additional steps of instructions would make it even more secure and harder for the user to crack and detect the whole algorithm (including the instructions), because if he discovers your formula and gets a result of 500898 (for example) he will have to figure out that the algorithm accepts only a few numbers of that number!

You can for example accept only the 1st,3rd,5th and so on, or you can apply another formula to that result! So you get a result from the first algorithm/formula, and than to that result you can add another formula. So it will be even harder for the user to crack! All you need to do is just know how to make this into your program, therefore you do need some good programming skills to achieve this, because perhaps the mathematical function can be made easily, but the instruction part might be difficult. And remember having a complicated algorithm is always better than having a simple one, so don’t be lazy, make the best you can, once the algorithm is done at least you can have a more hard to crack application, but as always it is not hack proof, and besides that read my Cracking tutorial here:
So you can make an even better application, because it will be useless having a very complicated algorithm and then not having a secure application! Because with a simple process it can be cracked easily without the need of knowing the algorithm!

Now just to help you out this is a simple pseudo code, might help you when it comes to implement it into your program:

Number1 = Get Value of First Text box
Number2 = Get Value of Second Text box
Number3 = Get Value of Third Text box
Number4 = Get Value of Fourth Text box
Result = ((((Number1 + Number4) - Number3) / 2) * 5) ^ 2 //This is the formula, plain and simple
Result = Get The Result of the formula, Then Get the 2nd,3rd,4th,5th and 6th values of  it
If Result = Number2 Then 
MsgBox "Correct Registration Code"
Else MsgBox "Incorrect Registration Code”

  • 0

#2 bbqroast


    Codecall Addict

  • Senior Member
  • PipPipPipPipPipPip
  • 564 posts
  • Location:/etc/passwd

Posted 02 September 2010 - 04:21 PM

Nice tutorial!!
What if you made a program where you needed internet when your registered,
Then some of the parts of the algorithim where sent from the server (if it was A*5+(6*D) and the server sent D)
  • 0
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#3 fishsticks


    CC Regular

  • Just Joined
  • PipPipPip
  • 33 posts

Posted 09 January 2011 - 08:47 AM

This is great! What code is this in exactly?
  • 0

Also tagged with one or more of these keywords: registration

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download