Go by Example: SHA256 Hashes
Go by Example : SHA256 Hashes
SHA256 hashes are frequently used to compute short identities for binary or text blobs. For example, TLS/SSL certificates use SHA256 to compute a certificate’s signature. Here’s how to compute SHA256 hashes in Go. | |
| |
Go implements several hash functions in various
|
|
| |
Here we start with a new hash. |
|
|
|
This gets the finalized hash result as a byte
slice. The argument to
|
|
|
Running the program computes the hash and prints it in a human-readable hex format. |
|
You can compute other hashes using a similar pattern to
the one shown above. For example, to compute
SHA512 hashes import
| |
Note that if you need cryptographically secure hashes, you should carefully research hash strength ! |
Next example: Base64 Encoding .