[AS3]as3.0随机数组合,as3生成随机数
[AS3]as3.0随机数组合,as3生成随机数
[AS3]as3.0随机数组合,as3生成随机数
- function createRandomPassword(hashLen:uint, includeLowercase:Boolean = true, includeNumbers:Boolean = true, includeUppercase:Boolean = false):String {
- var strHash:String = "";
- if (includeLowercase) strHash += "abchefghjkmnpqrstuvwxyz";
- if (includeNumbers) strHash += "0123456789";
- if (includeUppercase) strHash += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- var maskPick:Number;
- var passwordStr:String = "";
- var maskLen:uint = strHash.length;
- for (var i:uint = 0; i < hashLen; i++) {
- maskPick = Math.floor(Math.random() * maskLen);
- passwordStr += strHash.charAt(maskPick);
- }
- return passwordStr;
- }
- trace(createRandomPassword(8));
- // Output
- // 6k3x10h8j
- trace(createRandomPassword(6, true, true, true));
- // Output
- // D2jHEfT
- trace(createRandomPassword(16, false, true, true));
- // cuplayer.com:Output
- // O8I2DTSLHHWRI50Z
- trace(createRandomPassword(16, true, false, false));
- // cuplayer.com:Output
- // xxfeyshhqkrsqvhjt
- trace(createRandomPassword(16, false, false, true));
- // cuplayer.com:Output
- // XMXIDTIXMNGNUXZT
- trace(createRandomPassword(16, false, true, false));
- // cuplayer.com:Output
- // 4026352375069424
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...