verify.js
"use strict";
function VerifyCode(canvas, codeLength){
this._canvas = canvas;
this._context = canvas.getContext('2d');
this._canvasWidth = canvas.width;
this._canvasHeight = canvas.height;
this._codeLength = codeLength;
this._code = null;
}
VerifyCode.prototype = {
constructor : VerifyCode,
_randCode : function(){
var result = [];
for(var i = 0;i < this._codeLength; i++){
var randSeed = Math.random();
if(randSeed < 0.5){//数字
result.push(String.fromCharCode(48 + parseInt(Math.random() * 10)));
}
else if(randSeed < 0.8){//大写
result.push(String.fromCharCode(65 + parseInt(Math.random() * 10)));
}
else{//小写
result.push(String.fromCharCode(97 + parseInt(Math.random() * 10)));
}
}
this._code =