File manager - Edit - /home/pack/api-secure/test_ui.html
Back
<!DOCTYPE html> <html lang="th"> <head> <meta charset="UTF-8"> <title>Token + Signature Test Tool</title> <style> body { font-family: Arial; padding: 20px; } input, button { padding: 10px; width: 100%; margin-top: 5px; } </style> </head> <body> <h2>🔐 Token + Signature Tester</h2> <p>ทดสอบระบบความปลอดภัยก่อนเขียน Flutter ได้ง่ายๆ</p> <label>Token</label> <input id="token" value="PACKBEACON2025"> <label>Secret</label> <input id="secret" value="PackBeacon@Secure!"> <label>Timestamp</label> <input id="timestamp" placeholder="เช่น 1733200000"> <button onclick="genSig()">Generate Signature</button> <button onclick="verifySig()">Verify Signature</button> <h3>🔑 ผลลัพธ์</h3> <pre id="output"></pre> <script> function genSig() { const token = document.getElementById("token").value; const secret = document.getElementById("secret").value; const ts = document.getElementById("timestamp").value || Math.floor(Date.now()/1000); const text = token + ts; crypto.subtle.importKey( "raw", new TextEncoder().encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"] ).then(key => { return crypto.subtle.sign("HMAC", key, new TextEncoder().encode(text)); }).then(sig => { const hex = [...new Uint8Array(sig)].map(b => b.toString(16).padStart(2,"0")).join(""); document.getElementById("output").textContent = JSON.stringify({ token: token, timestamp: ts, signature: hex }, null, 2); }); } function verifySig() { const token = document.getElementById("token").value; const ts = document.getElementById("timestamp").value; const sig = document.getElementById("output").textContent.match(/"signature": "(.*)"/)?.[1]; if (!token || !ts || !sig) { alert("กรุณาสร้าง signature ก่อน!"); return; } fetch("https://pack.iot-cm.com/api-secure/test_signature_verify.php?token=" + token + "×tamp=" + ts + "&signature=" + sig) .then(r => r.json()) .then(j => { document.getElementById("output").textContent = JSON.stringify(j, null, 2); }); } </script> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.41 |
proxy
|
phpinfo
|
Settings