短信验证码随机生成

package com.cxy.ums.util;

import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
/**  
 * @Author: feizi
 * @Date: 2015年4月17日 上午9:24:48 
 * @ModifyUser: feizi
 * @ModifyDate: 2015年4月17日 上午9:24:48 
 * @Version:V6.0
 * http://blog.csdn.net/hu1991die/article/details/45101651
 */
public class SendMessagegUtil {

    /**
     * 发送短信消息
      * 方法说明
      * @Discription:扩展说明
      * @param phones
      * @param content
      * @return
      * @return String
      * @Author: feizi
      * @Date: 2015年4月17日 下午7:18:08
      * @ModifyUser:feizi
      * @ModifyDate: 2015年4月17日 下午7:18:08
     */
//    @SuppressWarnings("deprecation")
//    public static String sendMsg(String phones,String content){
//        //短信接口URL提交地址
//        //String url = Constants.requestMessageUrl;
//        String url = "http://http.*******/";
//
//        Map<String, String> params = new HashMap<String, String>();
//
//        params.put("uid",Constants.uid.trim());
//        params.put("pwd", Constants.pwd);
//        //params.put("dxlbid", "短信类别编号");
//        //params.put("extno", "扩展编号");
//
//        //手机号码,多个号码使用英文逗号进行分割
//        params.put("mobile", phones);
//        //将短信内容进行URLEncoder编码
//        params.put("content", content);
//        params.put("encode", "utf8");
//        
//        
//        return HttpRequestUtil.postRequest(url, params);
//    }

    /**
     * 随机生成6位随机验证码
      * 方法说明
      * @Discription:扩展说明
      * @return
      * @return String
      * @Author: feizi
      * @Date: 2015年4月17日 下午7:19:02
      * @ModifyUser:feizi
      * @ModifyDate: 2015年4月17日 下午7:19:02
     */
    public static String createRandomVcode(){
        //验证码
        String vcode = "";
        for (int i = 0; i < 6; i++) {
            vcode = vcode + (int)(Math.random() * 9);
        }
        return vcode;
    }

    /**
     * 测试
      * 方法说明
      * @Discription:扩展说明
      * @param args
      * @return void
      * @Author: feizi
      * @Date: 2015年4月17日 下午7:26:36
      * @ModifyUser:feizi
      * @ModifyDate: 2015年4月17日 下午7:26:36
     */
//    public static void main(String[] args) {
//      System.out.println(SendMsgUtil.createRandomVcode());
//      System.out.println("&ecb=12".substring(1));
//        System.out.println(sendMsg("100000000", "尊敬的用户,您的验证码为" + SendMessagegUtil.createRandomVcode() + ",有效期为60秒,如有疑虑请详询11110000(客服电话)【**】"));
//        System.out.println(sendMsg("18600314282", "尊敬的用户,您的**号已审核通过,账户名为“1234”,初始密码为“11111”,为了确保安全,建议您登录**号系统修改密码,如有疑虑请详询11110000(客服电话)【**】"));
//    }
}
 

猜你喜欢

转载自blog.csdn.net/rocrunwang/article/details/81198630