Home > Software engineering >  decode fnv128 hash in golang
decode fnv128 hash in golang

Time:09-17

I have some values stored as 128-bit FNV-1a hashes that I would like to "decode". From my understanding, although most hashes are one way, FNV is not a cryptographic hash. Is it possible to "decode" an FNV hash I created myself? I am using golang, example hash below.

value, err := json.Marshal("hello world")
if err != nil {
    fmt.Println(err)
}

fnv128 := fnv.New128a()
_, err = fnv128.Write(value)
if err != nil {
    fmt.Println(err)
}
hash := fnv128.Sum([]byte{})

// given the hash above, find the value "hello world"

CodePudding user response:

You can't "decode" a hash, because a hash is not an encoding, it is a one-way transformation. Just because this hash is not considered cryptographically secure doesn't mean you can reverse it.

Your option is a brute-force search, the feasibility depends on the total space you need to search for matching inputs.

  • Related