Cryptography is mandatory in the current modern world. In this era of big data and data science, it is important to make sure your data is protected from a malicious attack.

There are many algorithms and techniques to ensure that your system is secure and no unauthorized access will be done to your data.

Symmetric encryption is one of these techniques, and in this tutorial, I will show you how to do it in Go.

Note: The version of Go used in this tutorial is 1.14.7.


The symmetric-key encryption is a technique used to encrypt a message where there is only one secret key. This key is used on both parts of the process, that is, to encrypt and decrypt the message.

Using any kind of symmetric-key algorithm, a message is converted into a form that cannot be understood. Unless someone has the secret key. In this case, both the sender and the receiver have the same key (exchanged in some secure way) so they can send messages and understand each other.

The algorithm used determines the size of the key and the mode that the process of encryption or decryption is done. And, usually, longer the key, harder is to hack it and more secure is your encryption. For example, a 128-bits key can take up to billions of years to be broken by a normal computer.

There are two types of algorithms:

  • Block: the message is encrypted using fixed-size blocks. Example: DESAES, etc.
  • Stream: the message is encrypted taking individual characters. Example: RC4Salsa20, etc.

#encryption #decryption #programming #go #golang

A Short Guide to Encryption using Go
1.40 GEEK