## File: README.md

# $ qrcp

Transfer files over Wi-Fi from your computer to a mobile device by scanning a QR code without leaving the terminal.

[](https://goreportcard.com/report/github.com/claudiodangelis/qrcp)

Join the **Telegram channel** [qrcp_dev](https://t.me/qrcp_dev) or the [@qrcp_dev](https://twitter.com/qrcp_dev) **Twitter account** for news about the development.

---

## How does it work?



`qrcp` binds a web server to the address of your Wi-Fi network interface on a random port and creates a handler for it. The default handler serves the content and exits the program when the transfer is complete. When used to receive files, `qrcp` serves an upload page and handles the transfer.

The tool prints a QR code that encodes the text:

```
http://{address}:{port}/{random_path}
```

Most QR apps can detect URLs in decoded text and act accordingly (i.e., open the decoded URL with the default browser), so when the QR code is scanned, the content will begin downloading by the mobile browser.

### Demo

**Send files to mobile:**



**Receive files from mobile:**



---

## Installation

### Using Go (Latest Development Version)
Requires Go 1.18 or later:
```sh
go install github.com/claudiodangelis/qrcp@latest
```

### Prebuilt Binaries
Download the latest release for your platform from the [Releases](https://github.com/claudiodangelis/qrcp/releases) page.

| Platform    | Instructions                                                                             |
|-------------|------------------------------------------------------------------------------------------|
| **Linux**   | Extract the `.tar.gz` archive, move the binary to `/usr/local/bin`, and set permissions. |
| **Windows** | Extract the `.tar.gz` archive and place the `.exe` file in a directory in your `PATH`.   |
| **macOS**   | Extract the `.tar.gz` archive, move the binary to `/usr/local/bin`, and set permissions. |

### Package Managers

| Platform    | Package Manager | Command                                        |
|-------------|-----------------|------------------------------------------------|
| **Linux**   | ArchLinux (AUR) | `yay -S qrcp-bin` or `yay -S qrcp`             |
| **Linux**   | Debian/Ubuntu   | `sudo dpkg -i qrcp_<version>_linux_x86_64.deb` |
| **Linux**   | CentOS/Fedora   | `sudo rpm -i qrcp_<version>_linux_x86_64.rpm`  |
| **Windows** | WinGet          | `winget install --id=claudiodangelis.qrcp  -e` |
| **Windows** | Scoop           | `scoop install qrcp`                           |
| **Windows** | Chocolatey      | `choco install qrcp`                           |
| **macOS**   | Homebrew        | `brew install qrcp`                            |

### Confirm Installation
After installation, verify that `qrcp` is working:
```sh
qrcp --help
```

---

## Usage

### Send Files

| Action                      | Command Example                   |
|-----------------------------|-----------------------------------|
| **Send a file**             | `qrcp MyDocument.pdf`             |
| **Send multiple files**     | `qrcp MyDocument.pdf IMG0001.jpg` |
| **Send a folder**           | `qrcp Documents/`                 |
| **Zip before transferring** | `qrcp --zip LongVideo.avi`        |

### Receive Files

| Action                              | Command Example                  |
|-------------------------------------|----------------------------------|
| **Receive to current directory**    | `qrcp receive`                   |
| **Receive to a specific directory** | `qrcp receive --output=/tmp/dir` |

---

## Configuration

`qrcp` works without prior configuration, but you can customize it using a configuration file or environment variables.

### Configuration File
The default configuration file is stored in `$XDG_CONFIG_HOME/qrcp/config.yml`. You can specify a custom location using the `--config` flag:
```sh
qrcp --config /tmp/qrcp.yml MyDocument.pdf
```

### Configuration Options

| Key         | Type    | Description                                                                    |
|-------------|---------|--------------------------------------------------------------------------------|
| `interface` | String  | Network interface to bind the web server to. Use `any` to bind to `0.0.0.0`.   |
| `bind`      | String  | Address to bind the web server to. Overrides `interface`.                      |
| `port`      | Integer | Port to use. Defaults to a random port.                                        |
| `path`      | String  | Path to use in the URL. Defaults to a random string.                           |
| `output`    | String  | Default directory to receive files. Defaults to the current working directory. |
| `fqdn`      | String  | Fully qualified domain name to use in the URL instead of the IP address.       |
| `keep-alive` | Bool    | Keep the server alive after transferring files. Defaults to `false`.           |
| `secure`    | Bool    | Use HTTPS instead of HTTP. Defaults to `false`.                                |
| `tls-cert`  | String  | Path to the TLS certificate. Used only when `secure: true`.                    |
| `tls-key`   | String  | Path to the TLS key. Used only when `secure: true`.                            |

### Environment Variables
All configuration parameters can also be set via environment variables prefixed with `QRCP_`:
- `$QRCP_INTERFACE`
- `$QRCP_PORT`
- `$QRCP_KEEPALIVE`

---

## Advanced Usage

### Network Interface
To use a specific network interface:
```sh
qrcp -i tun0 MyDocument.pdf
```

To bind the web server to all interfaces:
```sh
qrcp -i any MyDocument.pdf
```

### HTTPS
Enable secure transfers with HTTPS by providing a TLS certificate and key:
```sh
qrcp --tls-cert /path/to/cert.pem --tls-key /path/to/cert.key MyDocument.pdf
```

---

## Shell Completion

`qrcp` provides shell completion scripts for Bash, Zsh, and Fish.

| Shell    | Command Example                             |
|----------|---------------------------------------------|
| **Bash** | `source <(qrcp completion bash)`            |
| **Zsh**  | `qrcp completion zsh > "${fpath[1]}/_qrcp"` |
| **Fish** | `qrcp completion fish | source`             |

---

## Authors and Credits

- **Author**: [Claudio d'Angelis](https://t.me/claudiodangelis)
- **Logo**: Provided by [@arasatasaygin](https://github.com/arasatasaygin) as part of the [openlogos](https://github.com/arasatasaygin/openlogos) initiative.
- **Releases**: Managed with [goreleaser](https://goreleaser.com).

---

## Clones and Similar Projects

| Project Name                                                                                 | Description                                                                        |
|----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| [qr-fileshare](https://github.com/shivensinha4/qr-fileshare)                                 | A similar idea executed in NodeJS with a React interface.                          |
| [instant-file-transfer](https://github.com/maximumdata/instant-file-transfer) _(Uncredited)_ | Node.js project similar to this.                                                   |
| [qr-filetransfer](https://github.com/sdushantha/qr-filetransfer)                             | Python clone of this project.                                                      |
| [qr-filetransfer](https://github.com/svenkatreddy/qr-filetransfer)                           | Another Node.js clone of this project.                                             |
| [qr-transfer-node](https://github.com/codezoned/qr-transfer-node)                            | Another Node.js clone of this project.                                             |
| [QRDELIVER](https://github.com/realdennis/qrdeliver)                                         | Node.js project similar to this.                                                   |
| [qrfile](https://github.com/sgbj/qrfile)                                                     | Transfer files by scanning a QR code.                                              |
| [quick-transfer](https://github.com/CodeMan99/quick-transfer)                                | Node.js clone of this project.                                                     |
| [share-file-qr](https://github.com/pwalch/share-file-qr)                                     | Python re-implementation of this project.                                          |
| [share-files](https://github.com/antoaravinth/share-files) _(Uncredited)_                    | Yet another Node.js clone of this project.                                         |
| [ezshare](https://github.com/mifi/ezshare)                                                   | Another Node.js two-way file sharing tool supporting folders and multiple files.   |
| [local_file_share](https://github.com/woshimanong1990/local_file_share)                      | _"Share local file to other people, OR smartphone download files which is in PC."_ |
| [qrcp](https://github.com/pearl2201/qrcp)                                                    | A desktop app clone of `qrcp`, written with C# and .NET Core, works for Windows.   |
| [swift_file](https://github.com/mateoradman/swift_file)                                      | Rust project inspired by `qrcp`.                                                   |
| [qrcp-android](https://github.com/ianfixes/qrcp-android)                                     | Android app inspired by `qrcp`.                                                    |

---

## License

MIT. See [LICENSE](LICENSE).

---

## File: docs/tutorials/secure-transfers-with-mkcert.md

# Secure transfers with mkcert

_Published on October 14th, 2020, by [Claudio d'Angelis](https://claudiodangelis.com)._


In this tutorial you will learn how to securely transfer files with qrcp by creating a local Certificate Authority using [mkcert](https://github.com/FiloSottile/mkcert) and generating a certificate for `qrcp`. From its README, **mkcert** _is a simple tool for making locally-trusted development certificates. It requires no configuration._

The following values will be used for this tutorial, they refer to a typical Linux system and may differ for you according to your operating system:

| Name  | Value |
| --- | --- |
| IP of the computer/laptop | `192.168.1.107` |
| Root certificate path | `~/.local/share/mkcert/rootCA.pem` |
| Certificate path | `~/certs/192.168.1.107.pem` |
| Certificate key | `~/certs/192.168.1.107-key.pem` | 
| Transferred file | `MyDocument.pdf` |

**Note**: secure transfers are only supported by `qrcp` version `0.7.0` and above.

## Generate certificates

Open your terminal, create a directory called `certs` and change to it
Install **mkcert** _(refer to the [README](https://github.com/FiloSottile/mkcert#installation))_.

Generate the Certificate Authority:
```
mkcert --install
```

If everything worked correctly, you should see the similar output:
```
Created a new local CA at "/home/me/.local/share/mkcert"
Sudo password:
The local CA is now installed in the system trust store! ⚡️
The local CA is now installed in the Firefox and/or Chrome/Chromium trust store (requires browser restart)!
```

Generate a certificate for the IP of your computer/laptop:

```
mkcert 192.168.1.107
```
You should see a similar output:

```
Using the local CA at "/home/me/.local/share/mkcert"

Created a new certificate valid for the following names 
 - "192.168.1.107"

The certificate is at "./192.168.1.107.pem" and the key at "./192.168.1.107-key.pem" 

```

At this point you should securely upload the root certificate generated by mkcert to your mobile phone. You have a few options for this, the simplest is just sending it by email. You can check the location of the root certificate's parent directory by running:

```
mkcert --CAROOT
```

If you are using **iOS**, you should _trust_ the certificate authority, you can find more information here: [Trust manually installed certificate profiles in iOS and iPadOS](https://support.apple.com/en-nz/HT204477).

If you are using **Android**, you must convert the root certificate from PEM format to DER format. Note that you may need to install the `openssl` tool.

```
openssl x509 -inform PEM -outform DER -in $(mkcert --CAROOT)/rootCA.pem -out $(mkcert --CAROOT)/rootCA.der.crt
```

Upload the converted certificate to your Android device, and install it by simply opening the file. When asked to enter the certificate name, you can enter a friendly name, for example "mkcert".

## Transfer something!

You are now ready to securely transfer a file using the certificates generated by mkcert:

```
qrcp --tls-cert ~/certs/192.168.1.107.pem --tls-key ~/certs/192.168.1.107-key.pem screenshot.png
```

The output will be something like this (note that the printed URL starts with "https"):
```
Scan the following URL with a QR reader to start the file transfer:
https://192.168.1.107:40221/send/ljd7
█████████████████████████████████████
█████████████████████████████████████
████ ▄▄▄▄▄ █ █▀▀ █▀ ▄█▄▀▀█ ▄▄▄▄▄ ████
████ █   █ █▀█▄▄▄▄▄▄█▄█▄██ █   █ ████
████ █▄▄▄█ ██▀▄▄▀▄▀█▀█ ▀▄█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ ▀▄█ ▀ ▀ ▀ █ █▄▄▄▄▄▄▄████
████ ▀▄ ▀▄▄ ▀██▀▄▄▄▄   ▄█▀▄██▄█▄ ████
████▀▀   █▄▀▀ ▄▄█▀ █▀▄█▄▀ ▄▄██▄▄▀████
████▀█ ▀█▄▄█ ▄██ ▀██▀▀  ▄█▀▀█▄ ▀▀████
████  █▀█▀▄ █  ▄ ▀▄   ▀▄██ █▀█▄ ▄████
█████ ▀ ▀▀▄  ▄▀█ ▀██▄█▄▀▄██ ▀ ▀ █████
████▄████▄▄  ▀█ ▀████▄█▄ ▄▀█ █ ██████
█████▄█▄▄▄▄█▀ ▀█  ▀ ▀▀   ▄▄▄   ▀▀████
████ ▄▄▄▄▄ █  █▄▄▄█ █▀█  █▄█  █▄▀████
████ █   █ █▀ ▀ ▄▀ █ █▀ ▄   ▄▀▄▄▄████
████ █▄▄▄█ █▄█▄█ ▀▀▀▄▀ █▄▄ █▀█▄▀▄████
████▄▄▄▄▄▄▄█▄▄▄██▄▄▄█▄▄██▄█▄█▄▄▄█████
█████████████████████████████████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
```

Scan the QR and the file will be securely transferred to your mobile. Congratulations!

## Configure qrcp to default to those value

If you want to make this setup persistent so that all transfers will be secured by default, run the wizard with `qrcp config` and make sure the choose the right values to the following questions:

_(**Note**: you must enter the **absolute path** of the certificates)_

- Should files be securely transferred with HTTPS?  
  **Yes**
- Choose TLS certificate path. Empty if not using HTTPS  
  **/home/user/certs/192.168.1.107.pem**
- Choose TLS certificate key. Empty if not using HTTPS  
  **/home/user/certs/192.168.1.107-key.pem**

After configuring qrcp, all transfers will be always secured.
If you'll want to temporarily disable security, just add the `--secure=false` flag.

Secure transfer:
```
qrcp MyDocument.pdf
```

Insecure transfer:
```
qrcp --secure=false MyDocument.pdf
```

## Conclusion

In this tutorial we have seen how to:
- create a local certificate authority with `mkcert`
- issue a certificate for your computer/laptop
- use that certificate to secure the transferring of a file with `qrcp`

If you want to learn more about HTTPS and secure connections, have a look at the [How HTTPS works ...in a comic!](https://howhttps.works/) website.

## Useful Links

- [qrcp homepage](https://github.com/claudiodangelis/qrcp)
- [mkcert homepage](https://github.com/FiloSottile/mkcert)
- [qrcp Telegram channel](https://t.me/qrcp_dev)

---

## File: docs/index.md

# $ qrcp

Transfer files over Wi-Fi from your computer to a mobile device by scanning a QR code without leaving the terminal.

[](https://goreportcard.com/report/github.com/claudiodangelis/qrcp)

Join the **Telegram channel** [qrcp_dev](https://t.me/qrcp_dev) or the [@qrcp_dev](https://twitter.com/qrcp_dev) **Twitter account** for news about the development.

---

## How does it work?



`qrcp` binds a web server to the address of your Wi-Fi network interface on a random port and creates a handler for it. The default handler serves the content and exits the program when the transfer is complete. When used to receive files, `qrcp` serves an upload page and handles the transfer.

The tool prints a QR code that encodes the text:

```
http://{address}:{port}/{random_path}
```

Most QR apps can detect URLs in decoded text and act accordingly (i.e., open the decoded URL with the default browser), so when the QR code is scanned, the content will begin downloading by the mobile browser.

### Demo

**Send files to mobile:**



**Receive files from mobile:**



---

## Installation

### Using Go (Latest Development Version)
Requires Go 1.18 or later:
```sh
go install github.com/claudiodangelis/qrcp@latest
```

### Prebuilt Binaries
Download the latest release for your platform from the [Releases](https://github.com/claudiodangelis/qrcp/releases) page.

| Platform    | Instructions                                                                             |
|-------------|------------------------------------------------------------------------------------------|
| **Linux**   | Extract the `.tar.gz` archive, move the binary to `/usr/local/bin`, and set permissions. |
| **Windows** | Extract the `.tar.gz` archive and place the `.exe` file in a directory in your `PATH`.   |
| **macOS**   | Extract the `.tar.gz` archive, move the binary to `/usr/local/bin`, and set permissions. |

### Package Managers

| Platform    | Package Manager | Command                                        |
|-------------|-----------------|------------------------------------------------|
| **Linux**   | ArchLinux (AUR) | `yay -S qrcp-bin` or `yay -S qrcp`             |
| **Linux**   | Debian/Ubuntu   | `sudo dpkg -i qrcp_<version>_linux_x86_64.deb` |
| **Linux**   | CentOS/Fedora   | `sudo rpm -i qrcp_<version>_linux_x86_64.rpm`  |
| **Windows** | WinGet          | `winget install --id=claudiodangelis.qrcp  -e` |
| **Windows** | Scoop           | `scoop install qrcp`                           |
| **Windows** | Chocolatey      | `choco install qrcp`                           |
| **macOS**   | Homebrew        | `brew install qrcp`                            |

### Confirm Installation
After installation, verify that `qrcp` is working:
```sh
qrcp --help
```

---

## Usage

### Send Files

| Action                      | Command Example                   |
|-----------------------------|-----------------------------------|
| **Send a file**             | `qrcp MyDocument.pdf`             |
| **Send multiple files**     | `qrcp MyDocument.pdf IMG0001.jpg` |
| **Send a folder**           | `qrcp Documents/`                 |
| **Zip before transferring** | `qrcp --zip LongVideo.avi`        |

### Receive Files

| Action                              | Command Example                  |
|-------------------------------------|----------------------------------|
| **Receive to current directory**    | `qrcp receive`                   |
| **Receive to a specific directory** | `qrcp receive --output=/tmp/dir` |

---

## Configuration

`qrcp` works without prior configuration, but you can customize it using a configuration file or environment variables.

### Configuration File
The default configuration file is stored in `$XDG_CONFIG_HOME/qrcp/config.yml`. You can specify a custom location using the `--config` flag:
```sh
qrcp --config /tmp/qrcp.yml MyDocument.pdf
```

### Configuration Options

| Key         | Type    | Description                                                                    |
|-------------|---------|--------------------------------------------------------------------------------|
| `interface` | String  | Network interface to bind the web server to. Use `any` to bind to `0.0.0.0`.   |
| `bind`      | String  | Address to bind the web server to. Overrides `interface`.                      |
| `port`      | Integer | Port to use. Defaults to a random port.                                        |
| `path`      | String  | Path to use in the URL. Defaults to a random string.                           |
| `output`    | String  | Default directory to receive files. Defaults to the current working directory. |
| `fqdn`      | String  | Fully qualified domain name to use in the URL instead of the IP address.       |
| `keep-alive` | Bool    | Keep the server alive after transferring files. Defaults to `false`.           |
| `secure`    | Bool    | Use HTTPS instead of HTTP. Defaults to `false`.                                |
| `tls-cert`  | String  | Path to the TLS certificate. Used only when `secure: true`.                    |
| `tls-key`   | String  | Path to the TLS key. Used only when `secure: true`.                            |

### Environment Variables
All configuration parameters can also be set via environment variables prefixed with `QRCP_`:
- `$QRCP_INTERFACE`
- `$QRCP_PORT`
- `$QRCP_KEEPALIVE`

---

## Advanced Usage

### Network Interface
To use a specific network interface:
```sh
qrcp -i tun0 MyDocument.pdf
```

To bind the web server to all interfaces:
```sh
qrcp -i any MyDocument.pdf
```

### HTTPS
Enable secure transfers with HTTPS by providing a TLS certificate and key:
```sh
qrcp --tls-cert /path/to/cert.pem --tls-key /path/to/cert.key MyDocument.pdf
```

---

## Shell Completion

`qrcp` provides shell completion scripts for Bash, Zsh, and Fish.

| Shell    | Command Example                             |
|----------|---------------------------------------------|
| **Bash** | `source <(qrcp completion bash)`            |
| **Zsh**  | `qrcp completion zsh > "${fpath[1]}/_qrcp"` |
| **Fish** | `qrcp completion fish | source`             |

---

## Authors and Credits

- **Author**: [Claudio d'Angelis](https://t.me/claudiodangelis)
- **Logo**: Provided by [@arasatasaygin](https://github.com/arasatasaygin) as part of the [openlogos](https://github.com/arasatasaygin/openlogos) initiative.
- **Releases**: Managed with [goreleaser](https://goreleaser.com).

---

## Clones and Similar Projects

| Project Name                                                                                 | Description                                                                        |
|----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| [qr-fileshare](https://github.com/shivensinha4/qr-fileshare)                                 | A similar idea executed in NodeJS with a React interface.                          |
| [instant-file-transfer](https://github.com/maximumdata/instant-file-transfer) _(Uncredited)_ | Node.js project similar to this.                                                   |
| [qr-filetransfer](https://github.com/sdushantha/qr-filetransfer)                             | Python clone of this project.                                                      |
| [qr-filetransfer](https://github.com/svenkatreddy/qr-filetransfer)                           | Another Node.js clone of this project.                                             |
| [qr-transfer-node](https://github.com/codezoned/qr-transfer-node)                            | Another Node.js clone of this project.                                             |
| [QRDELIVER](https://github.com/realdennis/qrdeliver)                                         | Node.js project similar to this.                                                   |
| [qrfile](https://github.com/sgbj/qrfile)                                                     | Transfer files by scanning a QR code.                                              |
| [quick-transfer](https://github.com/CodeMan99/quick-transfer)                                | Node.js clone of this project.                                                     |
| [share-file-qr](https://github.com/pwalch/share-file-qr)                                     | Python re-implementation of this project.                                          |
| [share-files](https://github.com/antoaravinth/share-files) _(Uncredited)_                    | Yet another Node.js clone of this project.                                         |
| [ezshare](https://github.com/mifi/ezshare)                                                   | Another Node.js two-way file sharing tool supporting folders and multiple files.   |
| [local_file_share](https://github.com/woshimanong1990/local_file_share)                      | _"Share local file to other people, OR smartphone download files which is in PC."_ |
| [qrcp](https://github.com/pearl2201/qrcp)                                                    | A desktop app clone of `qrcp`, written with C# and .NET Core, works for Windows.   |
| [swift_file](https://github.com/mateoradman/swift_file)                                      | Rust project inspired by `qrcp`.                                                   |
| [qrcp-android](https://github.com/ianfixes/qrcp-android)                                     | Android app inspired by `qrcp`.                                                    |

---

## License

MIT. See [LICENSE](LICENSE).