Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to change the left padding char #9

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ Encrypt your data using the modern ChaCha20-Poly1305 cipher and export it into a

## run the api

The server can be started using a docker image.
The server can be started using a docker image:

```bash
docker run --rm -p 8000:8000 quay.io/allisson/secure-qrcode
```

Now the API server will be running on port 8000.

## api documentation.
## api documentation

You can access the API documentation using these two endpoints:
- http://localhost:8000/docs
- http://localhost:8000/redoc

## generate a secure QR code

Call the API passing at least the plaintext and key fields.
Call the API passing at least the plaintext and key fields:

```bash
curl --location 'http://localhost:8000/v1/encode' \
Expand All @@ -48,7 +48,7 @@ Use any program that read a QR code, the content will be something like this:
}
```

Now call the API passing the encrypted_data and the key.
Now call the API passing the encrypted_data and the key:

```bash
curl --location 'http://localhost:8000/v1/decode' \
Expand All @@ -69,3 +69,17 @@ curl --location 'http://localhost:8000/v1/decode' \
"decrypted_data": "my super secret text"
}
```

## about left padding char

The ChaCha20-Poly1305 works with a 32-byte secret key. When you use a secret key with less than 32 bytes, we need to use left padding until the required size is reached.

The default character for the left padding is the white space, which can be changed using the "secure_qrcode_left_padding_char" environment variable.

For example, when using the secret key "my super secret key" the value used in the encryption function will be "my super secret key ".

To start the server using another left padding char:

```bash
docker run --rm -p 8000:8000 -e secure_qrcode_left_padding_char=9 quay.io/allisson/secure-qrcode
```
Loading