跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
MediaWiki帮助
根类
所有页面
统计信息
分类树
特殊页面
FC
搜索
搜索
外观
登录
个人工具
登录
查看“︁随机密码生成器”︁的源代码
页面
讨论
简体中文
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
页面信息
外观
移至侧栏
隐藏
←
随机密码生成器
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
<html> <head> <meta charset="UTF-8"> <title>随机密码生成器</title> <style> body { font-family: Arial, sans-serif; text-align: center; } h1 { color: #333; } .container { margin: 20px auto; padding: 20px; max-width: 400px; border: 1px solid #ccc; border-radius: 5px; background-color: #f7f7f7; } .input-label { display: block; text-align: left; margin: 10px 0; font-weight: bold; } .input-checkbox { margin-left: 5px; } .generate-button { margin-top: 10px; background-color: #007bff; color: #fff; border: none; border-radius: 5px; padding: 10px 20px; cursor: pointer; } .generate-button:hover { background-color: #0056b3; } .copy-button { margin-top: 10px; background-color: #4CAF50; color: #fff; border: none; border-radius: 5px; padding: 10px 20px; cursor: pointer; } .copy-button:hover { background-color: #45a049; } .password-field { margin-top: 10px; } </style> <script> function generatePassword() { const length = document.getElementById("length").value; const useNumbers = document.getElementById("useNumbers").checked; const useSymbols = document.getElementById("useSymbols").checked; // Combine lowercase and uppercase letters into a single charset let charset = "abcdefghijklmnopqrstuvwxyz"; // Lowercase letters charset += charset.toUpperCase(); // Uppercase letters if (useNumbers) { charset += "0123456789"; } if (useSymbols) { charset += "!@#$%^&*()-_=+"; } if (charset === "") { alert("请选择至少一个字符集"); return; } let password = ""; for (let i = 0; i < length; i++) { const randomIndex = Math.floor(Math.random() * charset.length); password += charset[randomIndex]; } document.getElementById("password").value = password; } function copyPassword() { const passwordField = document.getElementById("password"); passwordField.select(); document.execCommand("copy"); alert("密码已复制到剪贴板"); } </script> </head> <body> <h1>随机密码生成器</h1> <div class="container"> <label for="length" class="input-label">密码长度:</label> <input type="number" id="length" min="1" max="100" value="12"> <br> <label class="input-label">包括以下字符集:</label> <input type="checkbox" id="useNumbers" class="input-checkbox" checked> 数字 <input type="checkbox" id="useSymbols" class="input-checkbox" checked> 特殊符号 <br> <button class="generate-button" onclick="generatePassword()">生成密码</button> <button class="copy-button" onclick="copyPassword()">复制密码</button> <div class="password-field"> <label for="password" class="input-label">生成的密码:</label> <input type="text" id="password" readonly> </div> </div> </body> </html>
返回
随机密码生成器
。
搜索
搜索
查看“︁随机密码生成器”︁的源代码
添加话题