captcha-cli
A simple captcha generator
I. Introduction
This is a simple captcha generator that utilizing pillow and pydub to generate captcha.
This also include a simple CLI to help you manage captcha level and data.
II. Installation
1. Base installation
You can install this package using pip:
pip install captcha-cli
or with uv:
uv add captcha-cli
2. manage installation
You can install this package with DB driver using pip:
pip install 'captcha-cli[manage]'
or with uv:
uv add 'captcha-cli[manage]'
This package comes with DB library (sqlalchemy) and default driver (aiosqlite)
3. api installation
You can install this package with API support using pip:
pip install 'captcha-cli[api]'
or with uv:
uv add 'captcha-cli[api]'
This package comes with DB part (sqlalchemy and aiosqlite) and API part (fastapi)
4. Using Docker
You can pull latest Docker image to your machine and use it:
docker pull git.vaito.dev/vair.nooi/captcha:latest
Or using dev image:
docker pull git.vaito.dev/vair.nooi/captcha:dev-latest
Or any dev build image:
docker pull git.vaito.dev/vair.nooi/captcha:<image id>
III. Usage
1. CLI
a. Add captcha level
-
Text captcha:
captcha add text --level <int> --angle <int> <int> --lines <int> <int> --dots <int> <int> --amplitude <int> --wavelength <int>-L / --level <int>act as the level id-a / --angle <int> <int>the range of the rotation angle of each character-l / --lines <int> <int>the range of the number of lines will be on the image-d / --dots <int> <int>the range of the number of dots will be on the image-A / --amplitude <int>the amplitude of distortion-w / --wavelength <int>the wavelength of distortion- Note
amplitudeandwavelengthwill decide how the picture will be bent
-
Audio captcha:
captcha add audio --level <int> --white-noise <int> <int> --pitch-shift <int> <int>-L / --level <int>act as the level id-w / --white-noise <int> <int>the range of the volume of the background noise, both int are negative number-p / --pitch-shift <int> <int>the range of the shift of each character pitch- Notes:
- For white noise volumne, -35 is very quiet, 0 is super dupper loud
- The pitch shift should be from 1 to 12
- The pitch is kinda useless
b. Delete captcha level
captcha delete --type [audio | text] --level <string>
-t / --type [audio | test]the type of the captcha-l / --level <string>the level id
c. List captcha levels
captcha list --type [audio | text]
-t / --type [audio | test]the type of the captcha
d. Generate captcha
captcha generate --type [audio | text] --level <string> --text <string> --length <int> --preview
-t / --type [audio | test]the type of the captcha-L / --level <string>the level id--text <string>the text to generate-k / --length <int>the length of random text-p / --previewpreview the captcha- Notes
- To use given text to generate captcha, use
--textoption - To use random text to generate captcha, use
--lengthoption --previewoption use pillowImage.show()for text captcha and pydubplay()for audio captcha--previewis required if you don't install package with DB option
- To use given text to generate captcha, use
e. Get all generated captcha (require DB installation)
captcha all --type [audio | text | both]
-t / --type [audio | text | both]captcha type filter
f. Start API server
captcha api --host <string> --port <int>
-h / --hostthe host adress-p / --portthe server port
2. API
Beside using CLI, you can also interact with app using API.
a. Start API
You can use this method
Or using Docker image:
docker run --name captcha -p 8000:8000 -v <path on your host>:/app/file git.vaito.dev/vair.nooi/captcha
b. Endpoints
-
POST
/captchaCreate a new captcha
-
Query:
type: "text" / "audio"captcha typenoise_level: stringcaptcha leveltext: string | null(default:null) predefined captcha answer, if null, use random textinclude_data: boolean(default:false) include base64 encoded captcha in the response
-
Return:
id: stringcaptcha id, use for getting answertype: "text" / "audio"captcha type, should match with the requested onedata: string | nullbase64 encoded captcha
-
-
POST
/solveSolve the captcha
-
Query:
id: stringcaptcha idanswer: stringcaptcha answer
-
Return:
status: "accepted" / "wrong"if the answer was true
-
-
GET
/captchaGet the captcha detail
-
Query:
id: stringcaptcha idwith_answer: boolean(defaultfalse) captcha answer, return error if env variableALLOW_GET_ANSWERis unset or set to false
-
Return:
id: stringcaptcha id, use for getting answertype: "text" / "audio"captcha typeanswer: stringcaptcha answer
-
Note: Field
answerin reponse would be omitted if querywith_answeris false
-
-
GET
/captcha/fileGet the captcha data
-
Query:
id: stringcaptcha id
-
Return:
- A JPG file if the captcha type is text
- or A WAV file if the captcha type is audio
-
IV. Env variables
| Name | Default value | Data type | Note |
|---|---|---|---|
| APP_LEVEL | Base on your installation | simple/manage/api | simple if you install captcha-climanage if you install captcha-cli[manage]api if you install captcha-cli[api] |
| DB_URL | sqlite+aiosqlite:///file/db.sqlite | string | Have to have the async dialect (driver) of the database (e.g. aiosqlite for sqlite)Should be accepted by sqlalchemy |
| ALLOW_GET_ANSWER | false | boolean | Set this to true to be able to get the captcha answer in API response |
| HOST | 127.0.0.1 | Any IP | |
| PORT | 8000 | integer |
Metadata
Release files for captcha-cli 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| captcha_cli-1.0.1.tar.gz | 3.1 MB | Without provenance | Details for captcha_cli-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| captcha_cli-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for captcha_cli-1.0.1-py3-none-any.whl |
Total release size: 6.2 MB
Release files / captcha_cli-1.0.1.tar.gz
| Download URL | captcha_cli-1.0.1.tar.gz |
|---|---|
| Size | 3.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ff7de15da84c491d4ccca141009357c14e8265bbaacdbc686aa6e1aa4b0b11d
|
|
BLAKE2b-256 checksum How to use checksums |
40f774b945c679dab0460205526fe8b4eb155bdb3a8f0a9eef13d6fc14ed9b84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / captcha_cli-1.0.1-py3-none-any.whl
| Download URL | captcha_cli-1.0.1-py3-none-any.whl |
|---|---|
| Size | 3.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
51f1975334a5aa5188e6de8069ddbc6f352c4956cbaad3b6bb84c06ea932e53f
|
|
BLAKE2b-256 checksum How to use checksums |
632550f692ef49b7f2c9bf1f267739ace3b47197206202817e0007a944d392df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for captcha-cli 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.