Skip to content

GonGe1018/ClockCAPTCHA

Repository files navigation

ClockCAPTCHA

🤖 AI-Generated Clock CAPTCHA Service

A clock image-based CAPTCHA service in the style of Google reCAPTCHA

FastAPI Python AI Powered License

🚀 Install and Start

1. Install repo

git clone https://github.com/GonGe1018/ClockCAPTCHA.git
cd ClockCAPTCHA
uv sync

2. env setting

cp .env.example .env
nano .env

3. server run

python main.py

The server runs at http://localhost:8000! 🎉

💻 Example

Web

<!DOCTYPE html>
<html>
<head>
    <title>My Website</title>
</head>
<body>
    <form id="myForm">
        <input name="email" placeholder="이메일" required>
        
        <!-- ClockCAPTCHA widget -->
        <script src="http://localhost:8000/api.js" async defer></script>
        <div class="clock-captcha" data-sitekey="demo"></div>
        
        <button type="submit">sumbit</button>
    </form>
</body>
</html>

Backend

import requests

def verify_captcha(token):
    response = requests.post('http://localhost:8000/api/siteverify', {
        'token': token
    })
    return response.json().get('success', False)

if verify_captcha(user_token):
  # CAPTCHA passed - perform the actual task
  save_user_data()
else:
  # CAPTCHA failed - handle the error
  return "CAPTCHA verification failed"

🔧 API endpoints

endpoint method description
/demo GET demo page
/api.js GET JavaScript client library
/widget GET CAPTCHA widget iframe
/api/challenge GET new CAPTCHA challenge generation
/api/verify POST user answer verify
/api/siteverify POST server token verify

⚙️ env

# Security Settings
JWT_SECRET_KEY=your-secret-key-change-this-in-production
JWT_ALGORITHM=HS256
CAPTCHA_EXPIRY_MINUTES=5

# Server Settings
HOST=0.0.0.0
PORT=8000
CORS_ORIGINS=*
CORS_CREDENTIALS=true

# AI Settings
GENERATED_IMAGES_DIR=generated_captchas
NOISE_INTENSITY=0.6
OUTPUT_SIZE_WIDTH=256
OUTPUT_SIZE_HEIGHT=256
GRAYSCALE=false

Based on

Licence

MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published