Retour à 2iia.com

Générateur de Mot de Passe


Code à copier

<!DOCTYPE html>
<html lang="fr">

<head>
    <meta charset="UTF-8">
    <title>Générateur de Mot de Passe</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f0f0f0;
            margin: 0;
            margin-top: 30px !important;
        }

        @media (max-width: 768px) {
            body {
                flex-direction: column;
                height: auto;
                padding: 20px;
                margin-top: 150 !important;
            }
        }

        .generator {
            background-color: #fff;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 400px;
            text-align: center;
        }

        h1 {
            font-size: 24px;
            color: #333 !important;
        }

        h2 {
            font-size: 20px;
            color: #555 !important;
            margin-top: 20px;
        }

        label {
            display: block;
            margin: 10px 0 5px;
            font-weight: bold;
            color: #333 !important;
        }

        input[type="number"] {
            width: 100%;
            padding: 8px;
            margin-bottom: 15px;
            border: 1px solid #ccc;
            border-radius: 5px;
            box-sizing: border-box;
            color: #333 !important;
        }

        input[type="submit"],
        button {
            background-color: rgb(46, 26, 112);
            color: white;
            padding: 10px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            width: 100%;
            margin-top: 10px;
            color: white !important;
        }

        input[type="submit"]:hover,
        button:hover {
            background-color: rgb(72, 68, 190);
            color: white !important;
        }

        p {
            margin-top: 15px;
            font-size: 18px;
            color: #333 !important;
        }

        pre {
            background-color: #f8f8f8;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
            text-align: left;
            max-height: 200px;
            overflow-y: auto;
        }

        code {
            font-family: 'Courier New', Courier, monospace;
            font-size: 14px;
        }
    </style>
</head>

<body>
    <div class="generator">
        <br>
        <a href="http://www.2iia.com" style="display: inline-block; background-color: #ff6200; color: white; padding: 15px 40px; border-radius: 5px; text-decoration: none; font-size: 16px; margin-bottom: 20px; text-align: center; margin: 0 auto; ">Retour à 2iia.com</a>
        <br>
        <h1>Générateur de Mot de Passe</h1>
        <form method="POST" action="">
            <label>Longueur du mot de passe (6-20) :</label>
            <input type="number" name="length" min="6" max="20" required><br>

            <input type="submit" value="Générer">
        </form>

        <?php
        if ($_SERVER["REQUEST_METHOD"] == "POST") {
            $length = intval($_POST["length"]);
            $characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*";
            $password = "";


            if ($length < 6 || $length > 20) {
                echo "<p>Erreur : La longueur doit être entre 6 et 20 caractères.</p>";
            } else {
                for ($i = 0; $i < $length; $i++) {
                    $password .= $characters[rand(0, strlen($characters) - 1)];
                }
                echo "<p>Votre mot de passe : <strong>$password</strong></p>";
            }
        }
        ?>

        <h2>Code à copier</h2>
        <pre><code id="code-to-copy"><?php echo htmlspecialchars(file_get_contents(__FILE__)); ?></code></pre>
        <button onclick="copyCode()">Copier le code</button>
    </div>

    <script>
        function copyCode() {
            var code = document.getElementById("code-to-copy").innerText;
            navigator.clipboard.writeText(code);
            alert("Code copié !");
        }
    </script>
</body>

</html>