# Entering a passphrase

{% hint style="danger" %}
To ensure that files/private keys can always be decrypted, **only use** [**ASCII**](https://www.rfc-editor.org/rfc/rfc20) **characters in passphrases**. For example, use a [password manager](https://bitwarden.com/) to randomly generate passwords/passphrases.
{% endhint %}

## Interactively

There are three ways of entering a passphrase interactively:

1. Press `Enter` on your keyboard (instead of typing anything) to randomly generate a secure passphrase, which will be displayed in the terminal. **Make sure you copy this passphrase into a** [**password manager**](https://keepassxc.org/).
2. Type in your passphrase, press `Enter` on your keyboard, and retype the passphrase.
3. Paste your passphrase by right-clicking, press `Enter` on your keyboard, and paste the passphrase again.

{% hint style="info" %}
Kryptor uses UNIX style passphrase entry, meaning **nothing is displayed in the terminal when you type**. This prevents someone from seeing the passphrase characters and the length of the passphrase.
{% endhint %}

Here's what randomly generating a passphrase looks like:

```bash
$ kryptor -e -p file.txt

Enter a passphrase (leave empty for a random one):

Randomly generated passphrase: lethargic-shivering-confirm-doable-unlearned-fragility-aim-glitch
```

Here's what typing a passphrase looks like:

```bash
$ kryptor -e -p file.txt

Enter a passphrase (leave empty for a random one):

Retype passphrase:

```

## Non-interactively

Instead of the above, you can specify `-p:"[passphrase]"` like so:

```bash
$ kryptor -e -p:"YeV$Ra7{_IJ]nN2v1m,ei9d+T" file.txt
```

To randomly generate a passphrase this way, you can specify `-p:" "` like so:

```bash
$ kryptor -e -p:" " file.txt

Randomly generated passphrase: dumpster-roundup-unviable-sanitizer-unsecured-budget-sinner-shindig
```

This method of passphrase entry can also be used for encrypting and decrypting a private key (e.g. for [generating a key pair](#generating-a-new-key-pair), [encrypting files](#using-a-private-key) with a private key, or [signing files](#sign-files)). However, you must specify `-x|--private` alongside non-interactive passphrase entry for file encryption/decryption.

Here are some examples:

```bash
$ kryptor -g -p:"w*%Ul=j.F>1e{6H,+#ZWhXYUl"
$ kryptor -e -x -p:"1yF+k5l9zezPB}R]Pe+|*;sra" file.txt
$ kryptor -d -x -p:"1yF+k5l9zezPB}R]Pe+|*;sra" file.txt.bin
$ kryptor -s -p:"w*%Ul=j.F>1e{6H,+#ZWhXYUl" file.txt
```

{% hint style="warning" %}
This shouldn't be used if someone else may see your screen.
{% 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.kryptor.co.uk/tutorial/entering-a-passphrase.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.
