読者です 読者をやめる 読者になる 読者になる

RetroWeb ~iPhoneとAndroidでハイブリッドゲームアプリ開発~

AIR for iOS+AndroidでSmartPhone Game ハイブリッドアプリ開発

最近作ったアプリ
100億本の抜け毛 100億匹のモナー DQ3闘技場アプリ モナーペット(進化)

どんな環境、プログラム言語でも、6文字で1000億通りのユニークIDを生成する方法

サーバー介さなくても、アプリだけで(というかどんな環境、プログラムでも)数桁でユニークID作れることに気づいたので関数を公開しました(さらにドットとカンマとか、見分けにくいものは除いてます。)

ただし、引数6桁なら1000億分の1、8桁なら100兆分の1までにはダブりますw
ソーシャルゲームの招待コードや短縮URL生成も、これもどき+カウントインクリメントなのかな〜

public static function generateUserHash(count:uint=6):String{	
	const hashArray:Array = [
		"0","1","2","3","4","5","6","7","8","9",
		"a","b","c","d","e","f","g","h","i","j",
		"k","%","m","n","?","p","q","r","s","t",
		"u","v","w","x","y","z","A","B","C","D",
		"E","F","G","H","+","J","K","L","M","N",
		"#","P","Q","R","S","T","U","V","W","X",
		"Y","Z","$","*","@","&","!","-","/"
	];
	var s:String = "";
	while(count--){
		s = s + RadArray(hashArray);//配列から、ランダムで1文字取り出し追加
	}
	return s; // ABC123 とかで1000億通り以上完成
}