1 回答

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超7個(gè)贊
也許我誤解了你的問(wèn)題,但這是你要找的嗎?
package main
import (
"crypto/md5"
"fmt"
"io"
)
func main() {
fmt.Printf("\nresult: %s", md5plus("123", 2))
}
func md5plus(text string, cost int) string {
for i := 0; i < cost; i++ {
fmt.Printf("Loop %d: %s", i+1, text)
hash := md5.New()
io.WriteString(hash, text)
text = fmt.Sprintf("%x", hash.Sum(nil))
fmt.Printf(" => %s\n", text)
}
return text
}
https://play.golang.org/p/ri-5m3RZ_8v
我知道您正試圖在您的版本中重用散列器,但據(jù)我了解,這不是該庫(kù)的用途。您寫(xiě)入它來(lái)計(jì)算單個(gè)哈希值,而不是輪數(shù)。
- 1 回答
- 0 關(guān)注
- 145 瀏覽
添加回答
舉報(bào)