on
SHA3 Hash in Golang (256-bit)
You can use the golang.org/x/crypto/sha3
[docs] package to perform SHA-3 encoding on a string. We have an example function below, it will take your string and write it as a hash. Then convert that binary back into a hexadecimal string using Sprintf
.
Advantages of Using SHA3
Security: SHA-3 was designed to provide higher security compared to SHA-2 by using a different construction called “sponge construction”, which makes it more resistant to various types of attacks, such as collision and preimage attacks.
Performance: SHA-3 is designed to perform well on a wide range of hardware platforms, from small embedded devices to large servers. This makes it a good choice for a variety of applications where performance is a concern.
Flexibility: SHA-3 comes in several variants with different output sizes, such as 224, 256, 384, and 512 bits. This allows users to choose the right size for their specific needs, balancing security and performance.
Example:
Install the package:
|
|
Here’s an example of how to use it:
|
|