Hash SHA1 func for Go

How create alternative function php for Go?

base64_encode(pack(‘H*’, SHA-1(“qwerty”)))

Here’s an example for sha1



How realization function - pack. -> http://php.net/manual/ru/function.pack.php
pack — Pack data into binary string

The pack('H*', ...) thing looks like hex encoding from what I can see in the manual. Check out https://golang.org/pkg/encoding/hex/ or just fmt.Sprintf("%x", ...).

1 Like

BTW, you know SHA-1 is insecure, right?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.