package itHeiMaTestz;
import java.util.Random;
import java.util.Scanner;
public class CODEYZ {
/**
* @param args
*/
public static String CheckCode(int len) {
Scanner input = new Scanner(System.in);
StringBuilder str = new StringBuilder();
String yzm = "";
// String code ="[a-zA-Z][0-9]";
String code = "abcdefghijkmnpqrstuvwxyzABCDEFGHIJKMNPQRSTUVWXYZ23456789";
Random ran = new Random();
for (int i = 0; i < len; i++) {
int index = ran.nextInt(code.length());
char ch = code.charAt(index);
str.append(ch);
}
System.out.println("原验证码?" + str);
System.out.println("请输入验证码");
yzm = input.next();
if (yzm.equalsIgnoreCase(String.valueOf(str)))
{
System.out.println("正确");
} else {
System.out.println("输入有误");
}
return str.toString();
}
public static void main(String[] args) {
CheckCode(4);
}
}
import java.util.Random;
import java.util.Scanner;
public class CODEYZ {
/**
* @param args
*/
public static String CheckCode(int len) {
Scanner input = new Scanner(System.in);
StringBuilder str = new StringBuilder();
String yzm = "";
// String code ="[a-zA-Z][0-9]";
String code = "abcdefghijkmnpqrstuvwxyzABCDEFGHIJKMNPQRSTUVWXYZ23456789";
Random ran = new Random();
for (int i = 0; i < len; i++) {
int index = ran.nextInt(code.length());
char ch = code.charAt(index);
str.append(ch);
}
System.out.println("原验证码?" + str);
System.out.println("请输入验证码");
yzm = input.next();
if (yzm.equalsIgnoreCase(String.valueOf(str)))
{
System.out.println("正确");
} else {
System.out.println("输入有误");
}
return str.toString();
}
public static void main(String[] args) {
CheckCode(4);
}
}