隨機驗證碼

2021-10-19 21:43:41 字數 2937 閱讀 3794

!

(function

(window, document)

if(object.prototype.tostring.

call

(options)

=="[object object]")}

else

this

.options.numarr =

"0,1,2,3,4,5,6,7,8,9"

.split

(",");

this

.options.letterarr =

getallletter()

;this

._init()

;this

.refresh()

;}**erify.prototype =},

/**生成驗證碼**/

refresh:

function()

else

ctx.textbaseline =

"middle"

; ctx.fillstyle =

randomcolor

(180

,240);

ctx.

fillrect(0

,0,this

.options.width,

this

.options.height);if

(this

.options.type ==

"blend"

)elseif(

this

.options.type ==

"number"

)else

for(

var i =

1; i <=

4; i++

)/**繪製干擾線**/

for(

var i =

0; i <

4; i++

)/**繪製干擾點**/

for(

var i =

0; i <

this

.options.width/

4; i++)}

,/**驗證驗證碼**/

validate:

function

(code)

else}}

/**生成字母陣列**/

function

getallletter()

/**生成乙個隨機數**/

function

randomnum

(min, max)

/**生成乙個隨機色**/

function

randomcolor

(min, max)

window.**erify = **erify;})

(window, document)

;

使用:

"v_container"

style

="width

: 200px;

height

: 50px;

">

div>

type

="text"

id="code_input"

value="

" placeholder

="請輸入驗證碼"

/>

"my_button"

>

驗證button

>

"js/**erify.js"

>

<

/script>

const verifycode =

new**erify()

; document.

getelementbyid

("my_button").

onclick

=function()

else

}<

/script>

class

="code-box flex-sb"

>

class

="code-input"

type

="text"

v-model

="verifycode"

placeholder

="請輸入驗證碼"

>

input

>

onclick

="changeverifycode()"

id="code"

class

="randomcode"

>

span

>

p>

function

createverifycode()

document.

getelementbyid

('code'

).innerhtml = codetext;

const randomcolor =

'#'+ math.

random()

.tostring(16

).substr(2

,6).

touppercase()

;const codeboxstyle = document.

getelementbyid

("code");

codeboxstyle.style.color = randomcolor;

codeboxstyle.style.bordercolor = randomcolor;

} window.onload = createverifycode

function

changeverifycode()

驗證碼隨機生成

pip install captcha驗證碼隨機生成 python 版本 3.6 captcha 版本 0.3 from captcha.image import imagecaptcha import numpy as np import matplotlib.pyplot as plt from...

隨機生成驗證碼

coding utf 8 created on mon sep 16 01 21 02 2019 author administrator import random from captcha.image import imagecaptcha import numpy as np from pil...

隨機生成驗證碼

private static int r private static int g private static int b private static stringbuffer buffer public static final char chars public static random ...