0

I am aware that you can do something like go to md5online.org or something, but I want to know how to do it manually. For example, you might encrypt it like by taking the length of it and turning the number to hexadecimal. I highly doubt that is how you do it, but that is just an example. I know it is impossible to decrypt it, unless you do guess and check

  • 2
    What do you mean by "manually"? You can do it on a paper, but it will take a lot of time. Otherwise, most of the languages expose a md5 function (if that's not the case, there should be a library's method available). Anyway, I strongly advise that you read the wikipedia page of the md5 algorithm. en.wikipedia.org/wiki/MD5 – Jules Lamur Aug 29 '19 at 1:32
  • 3
    It's not really clear what you're asking for. Do you want a description of the MD5 algorithm? That's described in RFC 1321 (or the MD5 Wikipedia page has a nice description). – Miles Budnek Aug 29 '19 at 1:33
  • something like md5sum < <(printf 'Hello world.') !? – F. Hauri Aug 30 '19 at 19:55
  • 1
    Please also note that it's not an encryption operation - it's a hashing operation. techsolvency.com/passwords/dehashing-reversing-decrypting (disclosure: my page) – Royce Williams Sep 1 '19 at 21:51
5

First of all, let's be clear: encryption (encipherment) and hashing are not the same thing. Hash functions convert an arbitrary-size input into a fixed-size output, which by necessity loses some data and is therefore not reversible. If there isn't any way to get back to the plain text - and there isn't, with a hash function; you might find something that produces the same digest but you can't prove it was the same as the original - then it's not encryption.

Second: you shouldn't be using MD5 for anything, anymore. It's broken. If you don't require security, there are non-cryptographic functions that are faster to compute and produce outputs which are smaller to store/transmit. If you need security at all, use a modern and secure cryptographic hash algorithm, such as a member of the SHA-2 or SHA-3 family.


With that all said: MD5 is an algorithm that operates on bits (although in practice nearly all implementations operate on bytes). There are multiple ways to encode text as bits (binary), most commonly ASCII (which is seven bits per character but widely extended to use the eighth bit of a byte to hold additional values), UTF-8 (each character is stored in one or more bytes), or UCS-2 (or its extension UTF-16, where each character is stored in two - or possibly more, with UTF-16 - bytes).

To hash anything, you take the input (might be encoded text, or an image file, or a network packet data structure, or...) as a buffer, and call the desired hash function with that buffer as an input parameter. For text in particular, you simply take a representation of the text in the desired binary encoding and pass it as the input buffer to the hash function. Every non-toy programming language has some native encoding of text (which may or may not be already suitable for use as a hash function's input buffer), and has functions to convert a text string to a byte array of a desired encoding.

All general-purpose programming languages should also have at least one library that implements the most common hash functions. You can also invoke programs to do it from the command line (or from a shell script), such as md5sum or openssl dgst -md5, although they might not be installed by default on your machine (depending on OS and install configuration).

0

If you have openssl installed, you can use openssl to take the md5 hash of a string, like so:

echo -n "test string" | openssl dgst -md5

result:

(stdin)= 6f8db599de986fab7a21625b7916589c
  • 2
    If you have openssl installed there's also a pretty high chance you have access to md5sum: echo -n "test string" | md5sum – Marius Aug 29 '19 at 23:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.