Miklix

MD2 Hash Code Calculator

Published: February 10, 2025 at 4:24:56 PM UTC

Hash code calculator that uses the Message Digest 2 (MD2) hash function to calculate a hash code based on text input or file upload.

The MD2 (Message Digest 2) hash function is a cryptographic hash function designed by Ronald Rivest in 1989. It was specifically optimized for 8-bit computers. Although now considered obsolete and insecure for cryptographic purposes, it is included here in case one needs to calculate a backwards-compatible hash code. It should not be used when designing new systems.

Full disclosure: I did not write the specific implementation of the hash function used on this page. It is a standard function included with the PHP programming language. I only made the web interface to make it publicly available here for convenience.


Calculate New Hash Code

Data submitted or files uploaded through this form will only be kept on the server for as long as it takes to generate the requested hash code. It will be deleted immediately before the result is returned to your browser.

Input data:



Submitted text is UTF-8 encoded. Since hash functions operate on binary data, the result will be different than if the text was in another encoding. If you need to calculate a hash of a text in a specific encoding, you should upload a file instead.



About the MD2 Hash Algorithm

I'm okay at simple math, but not extremely good and by no means consider myself a mathematician, so I will try to explain how this hash function works in terms that non-mathematicians can understand. If you prefer the full-on mathematics version, it's easy enough to find in plenty of other places on the web ;-)

Now, imagine you have a recipe that takes any ingredients (your message) and always turns them into exactly one small, 16-piece chocolate bar (the hash). No matter what your ingredients are or how big or small they are, you will always end up with the same size chocolate bar.

The goal of this recipe is that:

  1. You can't guess the ingredients just by looking at the chocolate.
  2. Even a tiny change in the ingredients makes the chocolate taste completely different, so you know if someone messed with the ingredients or the recipe.

Creating the chocolate bar is a three step process:


Step 1: Padding the Message (Making the Ingredients Fit)

Let's say you have a basket that holds exactly 16 apples (or ingredients). But what if you only have 14 apples? You would need to add 2 more to fill the basket. If you're short, you just add extra apples. For example:

  • If you need two more, you add two apples.
  • If you have more than 16, you need to fill the next basked. For example, if you have 28, you add four to get to 32 (two times 16).

This makes sure every basket is full before we move to the next step.


Step 2: Adding a Checksum (Secret Ingredient List)

Now, we create a secret ingredient list based on everything in the basket.

  • You go through each basket, look at the apples, and write down a secret code for each one.
  • This isn't just a copy - it's like adding up numbers in a strange way so that even if someone sneaks in and changes an apple, the list will look wrong.

This list helps you double-check that the ingredients haven’t been messed with later.


Step 3: Mixing It All Together (The Magic Blender)

Now comes the fun part - the mixing!

  • You have a 48-slot blender.
  • You throw in:
    1. The apples (your message).
    2. Some old mixture from before (starts empty for the first batch).
    3. A mix of the first two things.

Then you blend it. But not just once. You blend it 18 times, changing the speed and direction each round. This isn't normal blending - each round stirs the mixture in a special way so that even one different apple would make the whole chocolate taste different.


The Final Chocolate Bar (The Hash)

After all that blending, you pour out just the top 16 pieces of the mixture. That's your final chocolate bar - the MD2 hash. It looks nothing like the original apples, and if you tried to guess the original ingredients just from the chocolate, you would never be able to.

Remember:

  • Same ingredients = same chocolate.
  • Change even one apple = completely different chocolate.
  • You can't go backward - you can't figure out the original apples just from the chocolate.
Share on BlueskyShare on FacebookShare on LinkedInShare on TumblrShare on XShare on LinkedInPin on Pinterest

Mikkel Bang Christensen

About the Author

Mikkel Bang Christensen
Mikkel is the creator and owner of miklix.com. He has over 20 years experience as a professional computer programmer/software developer and is currently employed full-time for a large European IT corporation. When not blogging, he spends his spare time on a vast array of interests, hobbies, and activities, which may to some extent be reflected in the variety of topics covered on this website.