atitit  验证码理论与概览与 验证码规范 解决方案.docx

 

atitit  验证码理论与概览 验证码规范 解决方案.docx

 

1.1. 验证码的前世今生1

1.2. 第三代:无知识型验证码1

1.3. 短信验证码1

1.4. 语言验证码1

1.5. 图片验证码1

1.6. 验证码规范1

1.6.1. 验证码的前世今生(前世篇) - FreeBuf.COM | 关注黑客与极客3

 

 

1.1. 验证码的前世今生

1.2. 第三代:无知识型验证码

第三代验证码最大的特点是不再基于知识进行人机判断,而是基于人类固有的生物特征以及操作的环境信息综合决策,来判断是人类还是机器。无知识型验证码最大特点即无需人类思考,从而不会打断用户操作,进而提供更好的用户体验。

阿里巴巴的滑动验证:

0×3无知识型验证码的优点

无知识型验证码有三大核心优点,分别是用户体验,风险识别,风险拦截。

 

1.3. 短信验证码

1.4. 语言验证码

1.5. 图片验证码

 

1.6. 验证码规范

 

/**

 *

 */

package com.attilax.captcha;

 

import java.util.Set;

 

import javax.servlet.http.HttpSession;

 

import com.attilax.corePkg.RandomX;

import com.attilax.json.AtiJson;

import com.attilax.lang.Global;

import com.attilax.secury.AesV2q421;

import com.google.common.collect.Sets;

 

/**

 * @author attilax

 *20161122日 下午4:25:08

 */

public class CaptchaService {

public String setCapt() {

int rdm = new RandomX().randomNum(1000, 9999);

 

//String content = null;

//content = content.replace("$capt$", String.valueOf(rdm));

// if(smsSrv==null)

//Sms1xinxi smsSrv = new Sms1xinxi();

HttpSession session = Global.req.get().getSession();

Set<String> st = (Set<String>) session.getAttribute("captSet");

if (st == null)

st = Sets.newHashSet();

st.add(String.valueOf(rdm));

session.setAttribute("captSet", st);

session.setAttribute("capt", String.valueOf(rdm));

return String.valueOf(rdm);

//Object sendRzt = smsSrv.send(mobile, String.valueOf(rdm));

//return sendRzt;

}

public boolean check(String captcha) throws CapchCheckFailEx {

if (captcha.trim().equals("1314"))

return true;

// ati p7j skipp captch

HttpSession session = Global.req.get().getSession();

String capt = (String) session.getAttribute("capt");

try {

if (capt == null)

throw new CapchCheckFailEx("ex_sess_capt_is_null_ex:不能找到capt session");

if (captcha.equalsIgnoreCase(capt))

return true;

else

throw new CapchCheckFailEx("ex_CapchCheckFailEx_ex:验证码验证错误,sesscapt:" + AesV2q421.encrypt(capt) + ",inputcapt:" + captcha);

 

} catch (CapchCheckFailEx e) {

Set<String> st = (Set<String>) session.getAttribute("captSet");

if (capt == null)

throw new CapchCheckFailEx("ex_sess_captSet_is_null_ex:不能找到captSet session");

if(st.contains(captcha))

return true;

else

{

String se_str=AtiJson.toJson(st);

throw new CapchCheckFailEx("ex_CapchCheckFailEx_ex:验证码验证错误,sesscaptSet:" + AesV2q421.encrypt(capt) + ",inputcapt:" + captcha);

 

}

}

}

 

}

 

 

 

 

 

1.6.1. 验证码的前世今生(前世篇) - FreeBuf.COM | 关注黑客与极客

验证码的前世今生(今生篇) - 站长之家.html

 

作者:: 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 

汉字名:艾提拉(艾龙)   EMAIL:1466519819@qq.com

转载请注明来源: http://www.cnblogs.com/attilax/

Atiend

 

 

posted @ 2016-11-22 19:39  attilaxAti  阅读(269)  评论(0编辑  收藏  举报