# En(De)coding & En(De)cryption

Now that we’ve introduced few cryptographic terms, let’s take a closer look at some of the most important concepts. We’ll first explore encoding and decoding to understand how they differ from encryption. Then, we’ll dive deep into encryption and decryption, explaining how they work and why they are essential for secure communication.

## Encoding & Decoding

Encoding is the process of converting data into a different format for compatibility, storage, or transmission. It does not involve secrecy or security but ensures that data can be properly processed by different systems. Encoding is commonly used in data transmission, file storage, and text representation.&#x20;

Decoding is the reverse process, where encoded data is converted back into its original form. Unlike decryption, decoding does not require a secret key—anyone with knowledge of the encoding scheme can decode the data.

### Examples of Encoding & Decoding

<figure><img src="/files/I4o99n1icMPSljyCtseM" alt=""><figcaption><p>Encode &#x26; Decode</p></figcaption></figure>

1. Base64: "`Hello World!`" —> `SGVsbG8gV29ybGQhCg==` —> "`Hello World!`"
2. URL Encoding: "`Hello World!`" → `Hello%20World%21` —> "`Hello World!`"

There are several tools available for cryptographic work, both online and offline. Many websites offer quick Base64, URL, or ASCII conversion, while offline tools like Python scripts, command-line utilities, and text editors with encoding support allow for more control and automation.

Below is a list of online tools:

1. [CyberChef - The Cyber Swiss Army Knife](https://gchq.github.io/CyberChef/)
2. [Decode.fr](https://www.dcode.fr/en)
3. [NCA Toolkit](https://toolkit.ncateam.xyz/) - Show us support :innocent:
4. [Crackstation](https://crackstation.net/) - Online Password Cracking Website
5. [Hashes](https://hashes.com/en/decrypt/hash) - Yet Another Online Password Cracking Website

Many other online encoding and decoding tools are also available.

## Encryption

Encryption is the process of transforming plaintext (readable data) into ciphertext (unreadable data) using a cryptographic algorithm and a key. The goal of encryption is to make the data unintelligible to anyone who doesn't have the correct key to decrypt it.

Encryption can be performed using various algorithms, with two main types:

1. **Symmetric Encryption**: Both the sender and receiver use the same key for encryption and decryption. The main challenge here is securely sharing the key between both parties. Example: **AES (Advanced Encryption Standard).**
2. **Asymmetric Encryption**: Involves a pair of keys: a public key used for encryption and a private key used for decryption. The public key can be freely shared, but the private key remains secret. Example: RSA, Elliptic Curve.

### Example of Encryption

Let's Encrypt `HELLO NCA` using AES. To do so, we will use this website: <https://www.devglan.com/online-tools/aes-encryption-decryption>

{% hint style="info" %}
You can use any website of your choice.
{% endhint %}

You can see the following image where we have `HELLO NCA` as Plain Text which we are going to encrypt. And if you Notice the Secret Key used it's `ThisIsTopSecret1`. And We have our Cipher Text which is Encrypted.

<figure><img src="/files/NfDbru1D5AYXtua2LCl6" alt=""><figcaption></figcaption></figure>

If I share this encrypted cipher text with anyone, they won’t be able to decrypt it. Why? Because I have only given them the cipher text, not our **key**.

But! But! But! What if I give them both our secret key and the cipher text? They can **Decrypt**.

## Decryption

Decryption is the reverse process of encryption. It converts ciphertext back into plaintext using a cryptographic algorithm and a key. The recipient uses the correct key to decrypt the data and recover the original message. In symmetric encryption, the same key is used for both encryption and decryption. In asymmetric encryption, the private key is used to decrypt data that was encrypted with the corresponding public key.

### Example of Decryption

Let's continue where we left off with encryption. We have the cipher text, and let's assume we also have the secret key.

If they have both the cipher text and the secret key, they can decrypt the cipher text and retrieve the original plaintext, as shown below:

<figure><img src="/files/Epk86WJDlQGHDJADDk2d" alt=""><figcaption></figcaption></figure>

In short, the following figure should provide a general idea of encryption and decryption:

<figure><img src="/files/kbZdIHaTGZli0zABl0n7" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
In the example above, we used AES as the algorithm, but there are many other algorithms that we will learn about in the upcoming sections.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://handbook.ncateam.xyz/fundamentals/cryptography/en-de-coding-and-en-de-cryption.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
