时间:2021-05-26
本文实例为大家分享了JS生成随机密码的具体代码,供大家参考,具体内容如下
题目:
输入一个正整数n,生成n个随机密码,其中包括数字,大小写字母。
代码:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> div{ width: 300px; height: 100px; background-color: lightblue; overflow: auto; } </style></head><body> <input type="text"> <button>生成</button> <div class="end"></div> <script> var oTn = document.getElementsByTagName("input")[0]; var oBtn = document.getElementsByTagName("button")[0]; var oDiv = document.querySelector(".end"); var password = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o", "p","q","r","s","t","u","v","w","x","y","z","A","B","C","D", "E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S", "T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9" ]; function pass(length){ var Str = ""; for(var i = 0 ; i<length;i++){ Str += password[Math.floor(Math.random()*password.length)]; } return Str; } oBtn.onclick = function(){ oDiv.innerHTML = pass(oTn.value); } </script></body></html>以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
使用PHP开发应用程序,尤其是网站程序,常常需要生成随机密码,如用户注册生成随机密码,用户重置密码也需要生成一个随机的密码。随机密码也就是一串固定长度的字符串,
使用PHP开发应用程序,尤其是网站程序,常常需要生成随机密码,如用户注册生成随机密码,用户重置密码也需要生成一个随机的密码。随机密码也就是一串固定长度的字符串,
linux随机密码生成工具mkpasswd详解及实例mkpasswd命令生成随机复杂密码,前提安装expect,然后执行mkpasswd命令即可生成随机的密码。
如用户注册生成随机密码,用户重置密码也需要生成一个随机的密码。随机密码也就是一串固定长度的字符串,文章整理了几种生成随机字符串的方法。方法一1、在33–126中
最近在研究发红包的功能,于是写了个红包的生成算法。红包生成算法的需求预先生成所有的红包还是一个请求随机生成一个红包简单来说,就是把一个大整数m分解(直接以“分为