> For the complete documentation index, see [llms.txt](https://www.ctfrecipes.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.ctfrecipes.com/cryptography/symmetric-cryptography/aes/mode-of-operation/ofb/encrypt-to-uncrypt.md).

# 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 %}
