Security

Learning cybersecurity - Hands-on activities on data encryption

Four hands-on encryption activities: file encryption with GPG, an encrypted VeraCrypt container, OpenSSL on Linux, and client-side encryption with Crypto-JS.

· 3 min read · level: intermediate

The importance of data encryption activities cannot be overstated in a digital world where threats to information security are everywhere. Data encryption consists in transforming information into a format that is unreadable without the matching decryption key, which protects that data against unauthorized access.

These activities offer a valuable opportunity to acquire practical skills in the field of data encryption, whether on Windows systems, Linux systems or web applications. Here are a few steps to get started on this subject.


1. File encryption with GPG (GNU Privacy Guard)

Description: This activity consists in using GPG to encrypt a file on Windows or Linux.

Objective: Understand the basics of file encryption and use GPG to protect sensitive data.

Steps:

  1. Install GPG on your system (on Linux, it may already be installed by default).
  2. Generate a key pair with the command gpg --gen-key fichier_à_chiffré.
  3. Encrypt a file with the command gpg --encrypt --recipient.
  4. Check the content of the encrypted file.
  5. Decrypt the encrypted file with the command gpg --decrypt fichier_chiffré.

2. Using VeraCrypt to create an encrypted container

Description : This activity involves creating an encrypted container with VeraCrypt, an open source disk encryption program.

Objective : Learn to create and use an encrypted container to store sensitive files.

Steps to carry out:

  1. Download and install VeraCrypt on your system.
  2. Create a new encrypted container, specifying the size and the type of encryption.
  3. Mount the encrypted container and access it through a virtual drive.
  4. Copy sensitive files into the mounted container.
  5. Unmount the encrypted container once you have finished accessing it.

3. Using OpenSSL to encrypt data on Linux

Description: This activity involves using OpenSSL, an encryption library, to encrypt data on a Linux system.

Objective: Learn to use OpenSSL to encrypt and decrypt sensitive data.

Steps to carry out:

  1. Install OpenSSL on your Linux system if it is not already installed.
  2. Generate a private key and a self-signed certificate with OpenSSL.
  3. Encrypt a file using the OpenSSL command.
  4. Decrypt the encrypted file using the OpenSSL command.

4. Encryption on the web with Crypto-JS

Description: This activity focuses on using the Crypto-JS library to encrypt text in a web application.

Objective: Learn to integrate Crypto-JS into a web application in order to encrypt data on the client side.

Steps to carry out:

  1. Download Crypto-JS from its GitHub repository, or include it through a CDN in your web project.
  2. Create a simple web page with a form containing a text field for the message to encrypt.
  3. Integrate Crypto-JS into your web page by including the JavaScript file in the <script> section.
  4. Write JavaScript code to encrypt the text entered in the form using Crypto-JS.
  5. Display the encrypted text to the user, or store it in a database on the server side.
  6. Offer the user the option to decrypt the encrypted text using the same web page with another form.
  7. Write JavaScript code to decrypt the encrypted text using Crypto-JS.
  8. Display the decrypted text to the user.

The answers will follow the steps to carry out shortly.