JavaScriptランダム文字列

496 ワード



	/**
	 *        
	 * @param {Object} length         ,  32
	 * @author huxiao [email protected]
	 */
	function randomChar(length)  {
		length = length || 32;
		var source = "abcdefghzklmnopqrstuvwxyz";
		var random = "";
		for(var i = 0;i < length; i++)  {
			random += source.charAt(Math.ceil(Math.random()*100000000)%source.length);
		}
		return random;
	}