Created
January 11, 2019 07:09
-
-
Save sangheonhan/2017213e27ac2798a0a2fd0b190076fb to your computer and use it in GitHub Desktop.
숫자, 알파벳 대소문자로 일정 길이의 무작위 키를 만들어주는 스크립트
This file contains hidden or 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
| #! /usr/bin/env php | |
| <?php | |
| $seed = array_merge(range('0', '9'), range('a', 'z'), range('A', 'Z')); | |
| $seed_size = count($seed); | |
| shuffle($seed); | |
| $length = (isset($argv[1])) ? intval($argv[1]) : 32; | |
| $randkey = ''; | |
| for ($i = 0; $i < $length; $i++) { | |
| $randkey .= $seed[mt_rand(0, $seed_size - 1)]; | |
| } | |
| echo "$randkey\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment