> For the complete documentation index, see [llms.txt](https://low-caps-hub.gitbook.io/lowcapshubterminal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://low-caps-hub.gitbook.io/lowcapshubterminal/encryption-section/encryption-converter.md).

# Encryption converter

User can change state of wallet encryption in any moment. We have built-in converter from .dat to .txt and opposite. The mechanism doesn't requier special skills. Program opens "C:\Low Caps Hub Terminal" and adjustes searching for .dat or .txt files, according to your choice.

<figure><img src="/files/0g9VsXDMqgWtXKErMFTD" alt=""><figcaption></figcaption></figure>

**.txt to .dat**

If you decide to encrypt your wallet, you need to set the encryption key. Just after that, your .txt file will be replaced by .dat.

```python
def encrypt_txt_to_dat(self):
    directory = "C:\\Low Caps Hub Terminal"
    if os.path.exists(directory):
        filepath = filedialog.askopenfilename(
            title="Select .txt Wallet File",
            filetypes=[("Text Files", "*.txt")],
            initialdir=directory
        )
    else:
        self.show_message("Create/Import wallet first.", "Error")
        return

    if not filepath:
        return
    with open(filepath, 'r') as file:
        wallet_data = file.read()
    passphrase, dont_encrypt = self.prompt_for_passphrase("Encrypt Wallet", allow_no_encrypt=True)
    if dont_encrypt:
        self.show_message("Encryption canceled. Wallet remains unencrypted.", "Info")
        return
    if not passphrase:
        self.show_message("Passphrase is required to encrypt the wallet.", "Error")
        return
    encrypted_data = encrypt_data(wallet_data.encode('utf-8'), passphrase)
    encrypted_filepath = filepath.replace('.txt', '.dat')
    with open(encrypted_filepath, 'wb') as file:
        file.write(encrypted_data)
    self.show_message(f"Encrypted wallet saved to {encrypted_filepath}", "Encryption Successful")
    os.remove(filepath)
```

\
\&#xNAN;**.dat to .txt**

If you would like do decrypt your wallet, you can do it. Of course during it, you need to enter your key/password as well.

```python
def decrypt_dat_to_txt(self):
    directory = "C:\\Low Caps Hub Terminal"
    if os.path.exists(directory):
        filepath = filedialog.askopenfilename(
            title="Select .dat Wallet File",
            filetypes=[("DAT Files", "*.dat")],
            initialdir=directory
        )
    else:
        self.show_message("Create/Import wallet first.", "Error")
        return

    if not filepath:
        return
    passphrase, _ = self.prompt_for_passphrase("Decrypt Wallet", allow_no_encrypt=False)
    if not passphrase:
        self.show_message("Passphrase is required to decrypt the wallet.", "Error")
        return
    with open(filepath, 'rb') as file:
        encrypted_data = file.read()
    decrypted_data = decrypt_data(encrypted_data, passphrase)
    if decrypted_data is None:
        self.show_message("Failed to decrypt the wallet. Incorrect passphrase or corrupted file.", "Error")
        return
    decrypted_filepath = filepath.replace('.dat', '.txt')
    with open(decrypted_filepath, 'w') as file:
        file.write(decrypted_data.decode('utf-8'))
    self.show_message(f"Decrypted wallet saved to {decrypted_filepath}", "Decryption Successful")
    os.remove(filepath)
```


---

# 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:

```
GET https://low-caps-hub.gitbook.io/lowcapshubterminal/encryption-section/encryption-converter.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.
