能不能用ramdom()类产生汉字、英语字母、数字、符号综合的验证码

解决方案 »

  1.   

    那么这样应该会更省事:
    private static final char[] CODERANDOM = "零壹贰叁肆伍陆柒捌玖abcdefg123456789+-*/=".toCharArray();
      

  2.   

    可以,不过没有必要。一般使用 除去 0 和 1 之外的 8 个数字,以及除去 I, l, o, O 等之外的大小写字母,随机 4 个就可以了。
      

  3.   

    方法有好多用unicode的值域和随机数建立关联,用随机数去取unicode的值
      

  4.   

    public static void main(String[] a) throws Exception
    {
    Random random = new Random(System.currentTimeMillis());

    // random.next


    char c1 = '人';
    char c2 = '鸟';
    int n1 = c2-c1;//中文

    int n2 = 90- 65;//大写字母
    int n3 = 122-97;
    StringBuffer sb = new StringBuffer();
    for(int i=0;i<5;i++){
    switch(random.nextInt(4))
    {
    case 0://中文
    sb.append((char)(c1+random.nextInt(n1)));
    break;
    case 1://数字
    sb.append(random.nextInt(10));
    break;
    case 2://大写字母
    sb.append((char)(65+random.nextInt(n2)));
    break;
    case 3://小写字母
    sb.append((char)(97+random.nextInt(n3)));
    }
    }
    System.out.println(sb);
    }写的玩,发现这种方法出来的汉字不是 随便一个人都能打出来的
      

  5.   

    可以 随机的产生 一个数字  让他对应 相应的 ASC 码啊