繁体   English   中英

js es6中是否有任何新的有效方法来生成随机密码

[英]is there any new and efficient method in js es6 for generating random password

我想知道 es6 是否有任何不同的随机方法? 有这样的方法,但我正在寻找唯一的密码(任何 ID)

如果您想生成一个随机单词(在这种情况下为密码),您可以使用

var randomstring = Math.random().toString(36).slice(-8);

编辑:要包含数字,您可以在一行中使用以下内容:

var randPassword = 
Array(10).fill("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").map(function(x) { return x[Math.floor(Math.random() * x.length)] }).join('');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM