-4

So I came across the following code in Go trying to explain how md5 hashing works.

package main

import (
    "crypto/md5"
    "fmt"
)

func HashFunc(word string) {

    hash := md5.New()
    bytes := []byte(word)

    hash.Write(bytes)
    hashValue := hash.Sum(nil)
    hashSize := hash.Size()

    for n := 0; n < hashSize; n += 4 {
        var val = uint32(hashValue[n])<<24 +
            uint32(hashValue[n+1])<<16 +
            uint32(hashValue[n+2])<<8 +
            uint32(hashValue[n+3])
        fmt.Printf("%x ", val)
    }
    fmt.Println()
}

I would simply like to know how to dencrypt any data that is encrypted by the above function.

1 Answers1

5

You don't

MD5 is a hash function, not an encryption function. The point of a hash function is that it is impossible to convert the output back into the input

colm.anseo
  • 19,337
  • 4
  • 43
  • 52
hardillb
  • 54,545
  • 11
  • 67
  • 105
  • The how do you communicate using hashing? I'm sorry if this is too vast to explain. In my head, you provide the other party with the hashing method and they can decipher the message sent. – Srijan-Sriv Dec 26 '21 at 11:21
  • 2
    No, hash functions are used to verify that a message has not been altered, you send the message, the output of the hash (and the type) and the recipient can use the same function and check that they get the same output. – hardillb Dec 26 '21 at 11:23