> For the complete documentation index, see [llms.txt](https://notes.kraken-security.ru/kraken/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.kraken-security.ru/kraken/krupicy-znanii/obshie-stati/shifruem-faily-na-kali-linux-s-pomoshyu-openssl.md).

# Шифруем файлы на Kali Linux с помощью OpenSSL

### Как зашифровать файл на Kali Linux <a href="#kak-zashifrovat-fail-na-kali-linux" id="kak-zashifrovat-fail-na-kali-linux"></a>

1. Будем шифровать файл в режиме счетчика. Открываем окно терминала Kali Linux.
2. Создаём текстовый файл, содержащий сообщение Secret:

```
kali@kali:~$ echo "Secret" > plain.txt
```

3\. Смотрим содержимое файла благодаря команде cat:

```
kali@kali:~$ cat plain.txt
```

4\. Шифруем файл и вводим пароль. Вот команда:

```
kali@kali:~$ openssl enc -aes-256-ctr -pbkdf2 -e -a -in plain.txt -out encrypted.txt
```

Флаг enc -aes-256-ctr → указывает на то, что нужно использовать блочный шифр aes256ctr.

Разберем строку:

**`aes`** → функция сопоставления, используемая в каждом блоке. В нашем случае — это упомянутый ранее шифр AES.

**`256`** → размер блока, у нас он 256 бит.

**`ctr`** → режим блочного шифрования CTR.

**`-pbkdf2`→**&#x444;ункция формирования ключа\
\
Флаг **`-e`** → приказывает библиотеке openssl зашифровать файл.

Флаг **`-a`** → преобразует двоичные данные в зашифрованном файле в формат Base64, чтобы упростить его вывод на экран в терминале.

**`-in`** и **`-out`**→ указывают подлежащий шифрованию файл и имя выходного файла соответственно.

5\. Чтобы открыть зашифрованный файл, выполните команду `cat`:

```
kali@kali:~$ cat encrypted.txt
```

### Как расшифровать зашифрованный файл на Kali Linux <a href="#kak-rasshifrovat-zashifrovannyi-fail-na-kali-linux" id="kak-rasshifrovat-zashifrovannyi-fail-na-kali-linux"></a>

1. Выполняем команду:

```
kali@kali:~$ openssl enc -aes-256-ctr -pbkdf2 -d -a -in encrypted.txt -out decrypted.txt
```

Флаг **`-d`** → приказывает openssl расшифровать файл.

2\. Введем пароль, который использовали ранее.

**Важно уточнение:** злоумышленник, который получил доступ к зашифрованному файлу, вероятно, не сможет его расшифровать, но может повредить его, изменив зашифрованные биты.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://notes.kraken-security.ru/kraken/krupicy-znanii/obshie-stati/shifruem-faily-na-kali-linux-s-pomoshyu-openssl.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
