Google Authenticator TOTP Generator

Jana kod 6 digit untuk autentikasi dua faktor

Contoh Secret Key:
BH2Y4PPMZZFZTEQV
JBSWY3DPEHPK3PXP
GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ

Contoh OTPAuth URL:
otpauth://totp/SGR95444861_my%3ASGR95444861_my?secret=BH2Y4PPMZZFZTEQV&issuer=SGR95444861_my
otpauth://totp/Google%3Auser@gmail.com?secret=JBSWY3DPEHPK3PXP&issuer=Google
otpauth://totp/Microsoft%3Auser@outlook.com?secret=GEZDGNBVGY3TQOJQ&issuer=Microsoft
Kod akan dihantar ke URL ini secara automatik
------
Tamat tempoh dalam: 30s
API Endpoints & Contoh Kod
Endpoints:
GET: /api/generate?secret=YOUR_SECRET&webhook_url=WEBHOOK_URL
POST: /generate dengan JSON payload

# GET Request
curl "http://localhost:8000/api/generate?secret=BH2Y4PPMZZFZTEQV&webhook_url=https://hook.make.com/xxx"

# POST Request
curl -X POST http://localhost:8000/generate \
  -H "Content-Type: application/json" \
  -d '{"secret":"BH2Y4PPMZZFZTEQV","webhook_url":"https://hook.make.com/xxx"}'

// Fetch API
fetch('/generate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    secret: 'BH2Y4PPMZZFZTEQV',
    webhook_url: 'https://hook.make.com/xxx'
  })
})
.then(response => response.json())
.then(data => {
  console.log('TOTP Code:', data.code);
  console.log('Expires in:', data.expires_in, 'seconds');
});

 'BH2Y4PPMZZFZTEQV',
    'webhook_url' => 'https://hook.make.com/xxx'
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
echo "TOTP Code: " . $data['code'];
?>

import requests
import json

# GET Request
params = {
    'secret': 'BH2Y4PPMZZFZTEQV',
    'webhook_url': 'https://hook.make.com/xxx'
}

response = requests.get('http://localhost:8000/api/generate', params=params)
data = response.json()

print(f"TOTP Code: {data['code']}")
print(f"Expires in: {data['expires_in']} seconds")

# POST Request
payload = {
    'secret': 'BH2Y4PPMZZFZTEQV',
    'webhook_url': 'https://hook.make.com/xxx'
}

response = requests.post('http://localhost:8000/generate', 
                        json=payload,
                        headers={'Content-Type': 'application/json'})

data = response.json()
print(f"TOTP Code: {data['code']}")