【问题标题】:Dencryption of md5 string in Go [duplicate]Go中md5字符串的解密[重复]
【发布时间】:2022-01-25 20:36:38
【问题描述】:

所以我在 Go 中遇到了以下代码,试图解释 md5 哈希是如何工作的。

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()
}

我只是想知道如何对上述函数加密的任何数据进行解密。

【问题讨论】:

标签: go encryption md5


【解决方案1】:

你没有

MD5 是哈希函数,不是加密函数。哈希函数的要点是不可能将输出转换回输入

【讨论】:

  • 你如何使用散列进行通信?如果这太庞大而无法解释,我很抱歉。在我的脑海中,你向对方提供哈希方法,他们可以破译发送的消息。
  • 不,散列函数用于验证消息没有被更改,您发送消息,散列的输出(和类型)和接收者可以使用相同的函数并检查他们得到相同的输出。
猜你喜欢
  • 1970-01-01
  • 2014-06-21
  • 2013-04-04
  • 2013-04-20
  • 2014-07-02
  • 1970-01-01
  • 2010-12-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多