Encryption
Encryption is different from hashing because it is reversible and the original message can be recovered. There are symmetric encryption methods that use a password or a shared key to encrypt and decrypt. There are also asymmetric encryption algorithms that operate with a public and private key pair. AES is an example of symmetric encryption, and it is used to encrypt ZIP files, PDF files, or an entire filesystem. RSA is an example of asymmetric encryption and is used for SSL, SSH keys, and PGP.
Cryptographically secure pseudo-random number generator (CSPRNG)
The math
and rand
packages do not provide the same amount of randomness that the crypto/rand
package offers. Do not use math/rand
for cryptographic applications.
Note
Read more about Go's crypto/rand
package at https://golang.org/pkg/crypto/rand/.
The following example will demonstrate how to generate random bytes, a random integer, or any other signed or unsigned type of integer:
package main import ( "crypto/rand" "encoding...