博客
关于我
java中随机生成26个字母组合的随机验证码
阅读量:593 次
发布时间:2019-03-11

本文共 585 字,大约阅读时间需要 1 分钟。

实现原理,通过随机生成1-52的随机数,然后从定义好的字母数字中取元素进行组合。

下面是代码:

public static void login(){   		String [] yan ={   				"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",};		int a = (int)(Math.random()*52);		int b = (int)(Math.random()*52);		int c = (int)(Math.random()*52);		int d = (int)(Math.random()*52);		String yanzhengma = yan[a]+yan[b]+yan[c]+yan[d];		System.out.println(yanzhengma);			}

也可以自行扩展实现数字加字母组合的验证码。

欢迎关注哦:

在这里插入图片描述

转载地址:http://ddktz.baihongyu.com/

你可能感兴趣的文章
Netty应用实例
查看>>
netty底层——nio知识点 ByteBuffer+Channel+Selector
查看>>
netty底层源码探究:启动流程;EventLoop中的selector、线程、任务队列;监听处理accept、read事件流程;
查看>>
Netty心跳检测
查看>>
Netty心跳检测机制
查看>>
netty既做服务端又做客户端_网易新闻客户端广告怎么做
查看>>
netty时间轮
查看>>
Netty服务端option配置SO_REUSEADDR
查看>>
Netty核心模块组件
查看>>
Netty框架内的宝藏:ByteBuf
查看>>
Netty框架的服务端开发中创建EventLoopGroup对象时线程数量源码解析
查看>>
Netty源码—1.服务端启动流程一
查看>>
Netty源码—1.服务端启动流程二
查看>>
Netty源码—2.Reactor线程模型一
查看>>
Netty源码—2.Reactor线程模型二
查看>>
Netty源码—3.Reactor线程模型三
查看>>
Netty源码—3.Reactor线程模型四
查看>>
Netty源码—4.客户端接入流程一
查看>>
Netty源码—4.客户端接入流程二
查看>>
Netty源码—5.Pipeline和Handler一
查看>>