Git Product home page Git Product logo

secure-qrcode's Introduction

secure-qrcode

Build Status Docker Repository on Quay

Encrypt your data using the modern ChaCha20-Poly1305 cipher and export it into a secure QR code.

access via browser

Open the url https://secure-qrcode.onrender.com on your browser (This is a free instance type and will stop upon inactivity, so be patient).

If you want to run this on your local machine, see the next section.

run the api

The server can be started using a docker image:

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

Now the API server will be running on port 8000 and you can open the url http://localhost:8000 on your browser.

api documentation

You can access the API documentation using these two endpoints:

generate a secure QR code

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

curl --location 'http://localhost:8000/v1/encode' \
--header 'Content-Type: application/json' \
--data '{
    "plaintext": "my super secret text",
    "key": "my super secret key"
}' | jq -r '.content' | base64 --decode > qrcode.png

Now you can open the qrcode.png file and do whatever you want.

decrypt the QR code

Use any program that read a QR code, the content will be something like this:

{
    "nonce": "PAhk6TKJAT7taGOH",
    "header": "/wxYPzrrSRLUTQ3WjpmpMA==",
    "ciphertext": "QygEEzUS2wFUmTJtupBtLHrf92Y=",
    "tag": "wNIaFK4YdTRa4p3PbvJboA=="
}

Now call the API passing the encrypted_data and the key:

curl --location 'http://localhost:8000/v1/decode' \
--header 'Content-Type: application/json' \
--data '{
    "encrypted_data": {
        "nonce": "PAhk6TKJAT7taGOH",
        "header": "/wxYPzrrSRLUTQ3WjpmpMA==",
        "ciphertext": "QygEEzUS2wFUmTJtupBtLHrf92Y=",
        "tag": "wNIaFK4YdTRa4p3PbvJboA=="
    },
    "key": "my super secret key"
}' | jq
{
  "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:

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

secure-qrcode's People

Contributors

allisson avatar github-actions[bot] avatar paulovitin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.