The Go package crypto/sha256 produces hexadecimal cryptographic hash (digest) of a message. You can play with the examples shared here and check the output in Go Playground (links shared below corresponding code snippets).
Let us see a working example:
Click to play with the above code
Here we've successfully encrypted "My secret message" using SHA256.
Things to note:
%X is used to print elements of a Slice in hexadecimal, i.e. base 16 with upper-case letters for A-F)
Question
Here the output is false. Why? It's simply because the two messages are different.
Click to play with the above code
Here's an excellent article about password encryption and security.
Let us see a working example:
Click to play with the above code
Here we've successfully encrypted "My secret message" using SHA256.
Things to note:
%X is used to print elements of a Slice in hexadecimal, i.e. base 16 with upper-case letters for A-F)
Question
- What happens if you replace %X with %x?
Here the output is false. Why? It's simply because the two messages are different.
Click to play with the above code
Here's an excellent article about password encryption and security.
No comments:
Post a Comment