| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>AES CBC Encryption and QR Code Generation</title>
- <script src="./crypto-js.min.js"></script>
- <script src="./qrcode.min.js"></script>
- <style>
- html,
- body {
- width: 100%;
- height: 98%;
- margin: 0;
- padding: 0;
- text-align: center;
- align-items: center;
- }
- </style>
- </head>
- <body>
- <h1>AES CBC Encryption and QR Code Generation</h1>
- <form method="post">
- <input type="text" name="userName" placeholder="User name">
- <br>
- <input type="text" name="password" placeholder="Password">
- <br>
- <br>
- <button type="submit" name="encryptAndGenerateQR">Encrypt & Generate QR Code</button>
- <button type="submit" name="UPDATEurl">UPDATEurl</button>
- </form>
- <br>
- <br>
- <div style="width: 100%; display: flex; justify-content:center">
- <div style="width: 256px; height: 256px; border: 1px solid black; padding: 2%" id="qrcode"></div>
- </div>
- <div id="AES_str" style="width: 89%; padding: 5%; word-break: break-all;"></div>
- <?php
- if (isset($_POST['encryptAndGenerateQR'])) {
- $userName = $_POST['userName'];
- $password = $_POST['password'];
- if ($userName == "UPDATEurl") {
- $encryptedText = $userName . ";" . $password . ";";
- } else {
- // Encryption
- $plaintext = "u_name@" . $userName . ";" . "u_password@" . $password . ";";
- $key = "A123061230612306";
- $iv = "0000000000000000";
- $encryptedText = openssl_encrypt($plaintext, 'AES-128-CBC', $key, 0, $iv);
- }
- // echo "<br>" . $encryptedText . "<br>";
- // Generate QR Code
- echo '<script>
- var qr = new QRCode(document.getElementById("qrcode"), {
- text: "' . $encryptedText . '",
- width: 256,
- height: 256,
- colorDark: "#000000",
- colorLight: "#ffffff",
- correctLevel: QRCode.CorrectLevel.H
- });
- document.getElementById("AES_str").innerHTML = "' . $encryptedText . '";
- </script>';
- } else if (isset($_POST['UPDATEurl'])) {
- $encryptedText = "UPDATEurl;" . $_POST['password'] . ";";
- echo '<script>
- var qr = new QRCode(document.getElementById("qrcode"), {
- text: "' . $encryptedText . '",
- width: 256,
- height: 256,
- colorDark: "#000000",
- colorLight: "#ffffff",
- correctLevel: QRCode.CorrectLevel.H
- });
- document.getElementById("AES_str").innerHTML = "' . $encryptedText . '";
- </script>';
- }
- ?>
- </body>
- </html>
|