這段真的忘記從哪來的,但相當實用,幫你產出亂碼字串,用的方式相當棒,先直接產生亂數再轉為 36 進位,其中帶入參數為想要產生幾位數的亂數。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateRandomAlphaNum(len) { | |
var rdmString = ""; | |
for (; rdmString.length < len; rdmString += Math.random().toString(36).substr(2)); | |
return rdmString.substr(0, len); | |
} |
沒有留言:
張貼留言