Gocrypt golang library for encryption / decryption with a tag field

Firda Safridi
2 min readOct 15, 2020


During the last decades, data security has become a major issue. Encryption and decryption data have recently been widely investigated and developed because there is a demand for stronger encryption and decryption which very hard to crack. Golang as a popular programming language today, really supports encryption and decryption such as AES, DES, and RC4.

By doing encryption/decryption data in Golang, we very often apply it in many fields in a structure type. Doing these things one by one is very tiring. Come on!! Let’s analyze!

The Problem

For example, there is JSON data with plain text. The objective is how to encrypt the phone number, ID and license number.

The expected must be done like below

The Idea

Using Golang struct field to an identifier which fields need to be encrypted and what algorithm that used.


Structure JSON using tag field gocrypt

The Implementation

Using Gocrypt library will be implemented like this:

Sample Encryption & Decryption using gocrypt


Using Gocrypt easy to maintenance which field needs to be encryption/decryption. There is 3 algorithm supported by gocrypt.

DES3 — Triple Data Encryption Standard

The DES ciphers are primarily supported for PBE standard that provides the option of generating an encryption key based on a passphrase.

AES — Advanced Encryption Standard

The AES cipher is the current U.S. government standard for all software and is recognized worldwide.

RC4 — stream chipper

The RC4 is supplied for situations that call for fast encryption, but not strong encryption. RC4 is ideal for situations that require a minimum of encryption.


If you interested in these projects. Feel free to use it.