License Key Generator Algorithm

суббота 11 маяadmin
License Key Generator Algorithm Rating: 5,7/10 5893 reviews

Hi/Lo is a algorithm used for generating unique keys for use in a database as a primary key. It uses a sequence-based hi-lo pattern to generate values. It can be used with domain-driven design (DDD). Hi/Lo is used in scenarios where an application needs its entities to have an identity prior to persistence. An alternative to Hi/Lo would be to generate keys as universally unique identifiers (UUID).

This class can generate and validate license key serial numbers. It can generate a string with a serial number for use as license key of a given length for using with a given application. The generated key includes characters of a specified character set and is formatted grouping characters in groups of a certain length. The class can also validate previously generated license keys. Blowfish is a good algorithm for this because the block size is 64 bits. Using public key cryptography to Generate License Keys A much better approach for ensuring the authenticity of the product keys is the use public key cryptography, like the well-known RSA. This uses different keys for.


The preconditions are:

  • There is a constant defined to hold the maximum low value. The value must be greater than zero. A suitable value could be 1000 or 32767.
  • There is a variable defined to hold the currently assigned high value and it is assigned the value 0 (zero).
  • There is a variable defined to hold the currently assigned low value and it is assigned the value of the maximum low value plus 1 (one).

The steps are:

  1. If the currently assigned low value is greater or equal than the maximum low value then call a function to fetch a new current high value and reset the currently assigned low value to 0 (zero).
  2. Assign a key by multiplying the currently assigned high value with the maximum low value and adding the currently assigned low value.
  3. Increment the currently assigned low value by 1 (one).


The current_lo (integer) and current_hi (integer) variables are internal state variables. The internal state is retained across invocations. The max_lo (integer) constant is a configuration option. get_next_hi is a function that retrieves a new high value from a database server. In a relational database management system this could be through a stored procedure.

Precondition: max_lo must be set to a value greater than zero.


Example implementation in Python.



Very briefly mentioned in the 2003 book Java Persistence for Relational Databases by Richard Sperko on page 236.[1]

Very briefly mentioned in the 2004 book Better, Faster, Lighter Java by Bruce Tate and Justin Gehtland on page 137.[2]

Very briefly mentioned in the 2004 book Enterprise Java Development on a Budget: Leveraging Java Open Source by Brian Sam-Bodden and Christopher M Jud on page 386.[3]

Explained in the 2015 book Learning NHibernate 4 by Suhas Chatekar on page 53 and 144–145.[4]

Mentioned in the 2017 book NHibernate 4.x cookbook on page 35.[5]

Mentioned in the 2018 book ASP.NET Core 2 Fundamentals on page 219.[6]

This implementation uses hi/lo algorithm to generate identifiers. Algorithm uses a high value retrieved from database and combines it with range of low values to generate a unique identifier. High value is from column next_id of table hibernate_unique_key buy default. But you can override this to use a different table. This algorithm also supports specifying a where parameter which can be used to retrieve high value for different entities from different rows of the hibernate_unique_key table.

— Suhas Chatekar, Learning NHibernate 4 (2015-07-31)

hilo needs a set of two numbers to work with. One is hi which is sourced from a database table and other is lo which is calculated by NHibernate. NHibernate combines these two numbers using a formula to generate a unique number that can be used as identifier.

— Suhas Chatekar, Learning NHibernate 4 (2015-07-31)

While auto incremented IDs are simpler, whenever you add an entity to the context, this addition forces the entity to be inserted to the database. That is because we can only retrieve the ID if the actual insertion happens in the case of auto incremented IDs. The HiLo algorithm frees us from this restriction by reserving the IDs beforehand using a database sequence.

— Onur Gumus and Mugilan T. S. Ragupathi, ASP.NET Core 2 Fundamentals (2018-08-30)


Supported by Entity Framework Core (ORM for .NET Core) with Microsoft SQL Server using the UseHiLo extension method.[7] Not supported by the predecessor Entity Framework.

Supported by Hibernate (ORM for Java) and NHibernate (ORM for .NET) through SequenceHiLoGenerator[8] and TableHiLoGenerator.[9] Had support since at least 2002. Had support since at least version version 3.2 with code authored by Gavin King.

Supported by Doctrine[10] (ORM for PHP) through TableGenerator.[11]

Supported by Marten[12] (persistence library for .NET) with PostgreSQL through HiLoSequence.[13]

Supported by RavenDB.[14]

Not supported by Apache Cayenne, ServiceStack.OrmLite, Ruby on Rails Active Record, Dapper, and Dashing.

See also[edit]

  • Domain-driven design (DDD)


  1. ^Sperko, Richard. Java persistence for relational databases. Apress. p. 236. ISBN9781590590713.
  2. ^Tate, Bruce; Gehtland, Justin. Better, faster, lighter Java (1st ed.). O'Reilly. p. 137. ISBN0-596-00676-4.
  3. ^Sam-Bodden, Brian; M Jud, Christopher. Enterprise Java development on a budget : leveraging Java open source technologies. Apress. p. 386. ISBN978-1-59059-125-3.
  4. ^Chatekar, Suhas (2015-07-31). Learning NHibernate 4 : explore the full potential of NHibernate to build robust data access code. Packt Publishing Ltd. p. 53. ISBN9781784392062.
  5. ^Liljas, Gunnar; Zaytsev, Alexander; Dentler, Jason (2017-01-31). NHibernate 4.x cookbook : over 90 incredible and powerful recipes to help you efficiently use NHibernate in your application (Second ed.). Packt Publishing Ltd. p. 35. ISBN9781784394110.
  6. ^Gumus, Onur; T. S. Ragupathi, Mugilan (2018-08-30). ASP.NET Core 2 fundamentals : build cross-platform apps and dynamic web services with this server-side web application framework. Packt Publishing Ltd. p. 219. ISBN9781789533552.
  7. ^'SqlServerPropertyBuilderExtensions.UseHiLo Method (Microsoft.EntityFrameworkCore)'.
  8. ^'NHibernate Object Relational Mapper'. GitHub. NHibernate. 14 November 2019. Retrieved 14 November 2019.
  9. ^'NHibernate Object Relational Mapper'. GitHub. NHibernate. 14 November 2019. Retrieved 14 November 2019.
  10. ^'DoctrineORMSequencingTableGenerator API'.
  11. ^'Doctrine Object Relational Mapper (ORM)'. GitHub. Doctrine. 14 November 2019. Retrieved 14 November 2019.
  12. ^'Marten - Sequential Identifiers with Hilo'.
  13. ^'Postgresql as a Document Database and Event Store for .Net Applications: JasperFx/marten'. GitHub. The Jasper Framework and Related Projects. 14 November 2019. Retrieved 14 November 2019.
  14. ^'HiLo Algorithm RavenDB 4.1 Documentation'.

External links[edit]

Retrieved from ''

Introduction :

A key generator or a Keygen is a computer program that will generate a valid « Product Serial or Key » in order to completely register a software.

The key generation process may require a name or e-mail to generate the serial, in other cases where no name or e-mail is required the validity of the serial may be checked by relying on hardware or using an algorithm that will play with the serial parts in order to determine if the provided key is correct or not.

Different from patching and serial phishing, keygenning is defined as one of the hardest cracking techniques based on the fact that when coding, a working keygen you need to fully understand how the serial checking algorithm is working. This algorithm may relay on cryptography for instance MD5 hashing.

So after understanding how the serial checking algorithm works, the reverser must code a computer program in thier favorite programming language that will generate a valid key, serial or license for the targeted software.

If the software requires a name or e-mail and they are involved in the generation algorithm inside the targeted software, the reverser has many ways to code a keygen : one of the simplest is to program a keygen that will relay on the SAME instructions used by the software to generate the serial. I think that this is what we call a « Ripped Keygen » . In my point of view, I don’t think that this is a good practice of keygenning because in many cases it’s similar to a copy/paste.

The best thing that can be done is coding an « Unripped Keygen », that will do the same but using a different set of instructions which will make you learn far better than ripping the keygeneration routine itself.

I – KeygenMe :

A keygenMe is a computer program completely made by reververs for other reversers, the only accepted solution for the KeygenMe is coding a valid keygen that will generate a valid serial or key according to what the keygenMe needs.

To make it « fun » and interesting I managed to code a KeygenMe in my favorite programming langage X86 assembly / MASM syntax with a serial checking algorithm that you will see in details, later in this article. The KeygenMe and Keygen download links are in the references below.

So I’ll pretend that I have Zero-knowledge about this KeygenMe and start from the examination until completely coding a Keygen. Let’s get started.

Examining the KeygenMe :

First of all, before starting to debug the KeygenMe you have to see what it demands from you: is it a serial ? A license file ? … etc

Let’s open it and see what it needs :

Finding a seeding/alive and complete batch is a gem. Hollywood dual audio movies 720p.

As you can clearly see, the KeygenMe needs our email address and a serial number. After entering a random WRONG serial the KeygenMe prints “Invalid Serial”.

With Zero-knowledge you can’t actually guess if, the serial is generated based on the e-mail or not, only debugging this KeygenMe will get you the answer. So let’s open it inside Immunity and see what it has for us.

I will start by checking what happens exactly after providing our e-mail to the KeygenMe:

As you see, I tried to write short comments in front of important instructions. So what the KeygenMe does with our e-mail, is checking for its validity by seeing if it has the “@” sign in it and if there are at least 4 characters before the @ sign.

Keep in mind that we’re not sure that the mail is used or not .Simply because it’s still stored at memory address 00403150.

As the serial checking routine is a little bigger to be shown in one image, I will explain it to you part by part.

Let’s see what the KeygenMe dœs directly after providing an input string, as you saw this input « 111122223333444455556666 » won’t get us anywhere. Let’s discover why :

Click to Enlarge

You can clearly see that the KeygenMe will check the input length, check if the string « ITS– » is present then locate 3 more dashes (–). As a result the serial general format should be given by the user this way : ITS-XXXX-XXXX-XXXX-XXXX, where ITS– is a harcoded string and X’s are unknown for us in the mean time.

Now let’s start analyzing the next part :

This set of instructions will simply skip the first DWORD which is “ITS-” and place each of the fourth different parts of the serial in an seperated memory location. For example the first part of the serial which will come after the hardcoded string, will be placed in a DWORD that is located in memory address 004051A8.

We can suppose now that the serial checking algorithm will deal with each part of the serial alone, but we cannot judge yet because the algorithm may also link between those different parts.

Anyway, let’s see what the next instructions are dealing with:

Click to Enlarge

In this phase, we started to deal with the serial checking algorithm. The serial that we have to provide must have 5 parts. Each part is recognized by a dash “-“. I said that the first part is hardcoded so in the algorithm the KeygenMe will directly start dealing with the second part. Let’s suppose that we provided this serial to the KeygenMe : ITS-1111-2222-3333-4444

If we had provided this serial, all the previous checks would have gone right. But this check wouldn’t have gone right because simply the 2nd part of the serial which is “1111” is WRONG.

Let’s try to see what’s wrong and how can we fix that.

As you can clearly see the KeygenMe works on moving the DWORD in the first part into EAX register, our input is “1111” so the EAX register should hold “31313131” which is the translation of “1111” from ASCII into a Hexadecimal format. Now twill substract « 30303030 » from EAX resulting in « 01010101 ».

This value will replace the existing value in 004051A8. Now, the KeygenMe will try to do a simple addition between those bytes : 01 + 01 + 01 + 01 = 04 which is not 10h, that’s why we will jump into the “invalid serial” message.

For the mean time you just need to note what you discovered here in a Notepad or somewhere you can remember it and move on to the third part of the checking routine.

The 3rd part checking is quite different from the second one, it will simply compare the first character of our input to the letter “O”, then adds the next two bytes to the 4Fh (which is O in hex) and substracts the last byte from the addition result, the final result should be held in BL and equals 8Fh.

Note: You can conclude that in this part it’s preferable to use Capital letters starting in hexadecimal from 41h to 5Ah in the serial (using numbers is not a bad idea either).

For now, let’s move on to the fourth part checking :

Click to Enlarge

The 4th part checking set of instructions are similar to the second part, the only difference that you can see is that 2 is substracted from the last byte of the 4th part of the serial. Then the resulted value is added to the previous total. The final result should be 10h.

E.I : If the user managed to pass all the previous checks with correct input or by patching jumps which is RESTRICTED in a KeygenMe. Here’s what will happen with the input “3333” :

33333333 – 30303030 = 03 03 03 03. Then : 03 + 03 + 03 = 09, and the substraction : 03 – 02 = 01. And the addition finally : 09 + 01 = 0Ah which is different from 10h, the jump will be then taken to the invalid serial message routine.

Let’s see what the last check has for us:

So, the same thing as the second part of the serial is happening here, the only difference is that the resulted value should be 12h instead of 10h. Then we have the conditional jump that will take us to the unwanted message when the resulted value differs from 12h.

Now as we discovered together how the KeygenMe works on checking the validity of our serial, part by part and that the e-mail has no relation at all with the serial checking algorithim let’s go and code a keygen for it.

II – Writing a Valid Keygen:

So now, we need to program a Keygen that will generate an infinite number of Random serials.So you will have to write it in your favorite programming language.

License Key Generator Algorithm

So to practice you are freely welcome to write the Keygen in any language you want and why not e-mail me your keygen to check it.

Random Value Generation :

One of the problems that you may face is how to code a keygen that will make you able to generate random characters for the serial.

Well, there are several ways to achieve this and I’m about to introduce you some techniques :

GetLocalTime : This API will work on getting the current date and time, the interesting thing here is taking advantage of seconds or milliseconds (which occupy the sixth and the seventh words in the SYSTEMTIME structure) in order to generate a value especially if you’re working on a multiple serial generation.

GetTickCount : This is also a Win32 API that will retreive the milliseconds that were elapsed since the system was started (MSDN), GetTickCount will return a 32bits value to eax register. We can take advantage of this returned value especially AL or AH if we’re interested in one byte. In addition, setting conditions in the code is obligatory to get the value in a specific range (Printable Characters).

Other Methods : There are many ways to generate random values, some of them are related to cryptography. Windows is providing CryptGenRandom function for this purpose.

Random Value Generation & Looping:

Let’s get back to the point where I said you must provide certain conditions when generating a random value, there are two cases here when using GetTickCount API :

The first one is obligatory, you’ll need to set a loop where the return value in AL or AH (if you’re interested in generating 1 byte) must be printable and/or in a specific ASCII characters range.

The second one is decided by the serial checking algorithm that will show you if there are additional conditions for example the Software will not accept a serial where two identical consecutive characters are provided.

This is the main reason why the serial generation process may take some seconds, because the keygen will keep looping until the right value is found relaying on conditions provided.

We can consider this as a drawback. However, we can turn this into a positive point in our keygen with a message that is telling the user to wait for a couple seconds until the valid serial is generated.

Serial Generation :

In the KeygenMe that we analyzed you noticed that each part of the serial (4 characters in each part) is checked alone, and also it depends on simple math operations like addition and substraction. So to generate a valid part of the serial we will need to set 3 random characters and solve a simple equation to determine the missing characters to get a valid serial.

Now, you may realize that additional loops must take place which will check if the result of the equation is also a printable ASCII character or not.

The Keygen:

Here is the Keygen source code written in x86 ASM / MASM32 syntax (some code is additional in the serial checking algorithm like trying to avoid two consecutive identical characters):

The serial generation steps are well commented step by step :

Running the keygen :

Assemble then link the keygen’s source code and run it . You will be able to generate multiple valid serial numbers for the KeygenMe by pressing Return key.

Click to Enlarge

III – Conclusion :

He is active as a “tentmaker” missionary, involved in several ministries in the area around the University. South African sources such as Kalahari only list some titles The other two books are available, but only in the print versions:The Office of Christ and its expression in the Church: Prophet Priest King. Tecnotest reflex keygen download torrent. He has full ministerial recognition by the FIEC in the UK and the Baptist Union in South Africa. He has four children; the eldest is working for Bentley(UK), the second is teaching in Somerset West in South Africa, the third is in Technology working for the British Wireless for the Blind Fund while the last is a teacher in Orpington, also in the UK.Published workPrint versions of most of the book titles on this site are readily available from the publisher, iUniverse (, or from other outlets, such as Amazon, or Barnes and Noble.

In this article you were able to see how to analyze a Serial Checking Algorithm and code a valid key generator that will help you generate different serial numbers. No hashing or cryptography was present in this KeygenMe and the algorithm was quite simple. In the next part I will try to introduce a more harder KeygenMe with a complete tutorial on how to code a valid Keygen for it.


KeygenMe & Keygen download :

Keygen Source Code :