代码如下 | 复制代码 |
packagecom.bwsk.modules.weixin.util;
importjava.util.Random; /** *随机生成8位数授权码 * */ publicclassRandomUtils { //生成8位数的 字母 大小随机 当做授权码 publicstaticString randomUtil(){ Random r =newRandom(); String code =""; for(inti =0; i<8; ++i) { inttemp = r.nextInt(52); charx = (char) (temp<26? temp +97: (temp %26) +65); code += x; } returncode; }
} |