# Encrypt to Uncrypt

AES mode OFB is a fully symmetric cipher as the encryption algorithm can be used to uncrypt datas.

## How it works ?

Remember, `ciphertext = plaintext ⊕ encrypt(iv)` so, what if the user want encrypt again the `ciphertext` ?

```
ciphertext = plaintext ⊕ encrypt(iv)

# if the user want encrypt again ciphertext then :
ciphertext2 = ciphertext ⊕ encrypt(iv)
ciphertext2 = plaintext ⊕ encrypt(iv) ⊕ encrypt(iv)
```

However, as explain here, the opposite of xor is xor itself, so `encrypt(iv) ⊕ encrypt(iv) = 0`\
and `x ⊕ 0 = x` so :

```
ciphertext2 = plaintext ⊕ encrypt(iv) ⊕ encrypt(iv)
ciphertext2 = plaintext ⊕ 0
ciphertext2 = plaintext
```

{% hint style="info" %}
That's why, using OFB mode, if the user will have access to the encrypt function without the uncrypt one, he must do not know the IV.
{% 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://www.ctfrecipes.com/cryptography/symmetric-cryptography/aes/mode-of-operation/ofb/encrypt-to-uncrypt.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.
