原生js 使用canvas实现的数字摇摆验证码

  • 仿似苹果手机的动态验证码,去除了粒子运动。

VerCode.js


<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title></title>
	</head>
	<body>
		<div id="code"></div>
	</body>
	<script src="components/VerCode.js"></script>
	<script>
		window.onload = function() {
			var verCode = VerCode.init("#code");
			verCode.start();
			
			console.log(verCode.getCode());
			
			setTimeout(function() {
				verCode.resetCode();
				console.log(verCode.getCode());
			}, 3000)

                        //verCode.addArc(verCode.options.contextBg,10,5); 如果觉得验证码过于清楚,可以手动再添加一些污点
		}
	</script>
</html>


posted @ 2021-06-09 16:23  可爱的黑精灵  阅读(80)  评论(0)    收藏  举报