Skip to content

Instantly share code, notes, and snippets.

@blackraccoon000
Created April 26, 2013 03:59
Show Gist options
  • Save blackraccoon000/5464968 to your computer and use it in GitHub Desktop.
Save blackraccoon000/5464968 to your computer and use it in GitHub Desktop.
ランダムパスワード生成(手抜き)
import java.util.Random;
/**************************************************************************************************
* Copyright (c) 2013. Yutaka Fujii *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
**************************************************************************************************/
public class Execution {
public static void main(String args[]){
char[] c = charBox();
for (int i=0;i<10;i++){
Random randomGen = new Random();
int ranNum = randomGen.nextInt(c.length);
System.out.print(c[ranNum]);
}
}
private static char[] charBox(){
char[] s = {'a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s','t',
'u','v','w','x','y','z',
'A','B','C','D','E','F','G','H','I','J',
'K','L','M','N','O','P','Q','R','S','T',
'U','V','W','X','Y','Z',
'1','2','3','4','5','6','7','8','9','0',
};
return s;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment