-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCaptcha_Genrator.py
56 lines (45 loc) · 1.38 KB
/
Captcha_Genrator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
Instructions
1. Install captcha: pip install captcha
2. download fonts and update the path in code
3. run the code
"""
from io import BytesIO
from tkinter import *
from random import *
from tkinter import messagebox
import string
from captcha.image import ImageCaptcha
image = ImageCaptcha(fonts=['C:/Users/Administrator/Downloads/ChelseaMarketsr.ttf', 'C:/Users/Administrator/Downloads/DejaVuSanssr.ttf'])
random=str(randint(100000,999999))
data = image.generate(random)
assert isinstance(data, BytesIO)
image.write(random,'out.png')
def verify():
global random
x=t1.get("0.0",END)
if (int(x)==int(random)):
messagebox.showinfo("sucsess", "verified")
else:
messagebox.showinfo("Alert", "Not verified")
refresh()
def refresh():
random=str(randint(100000,999999))
data = image.generate(random)
assert isinstance(data, BytesIO)
image.write(random,'out.png')
photo = PhotoImage(file="out.png")
l1.config(image=photo,height=100,width=200)
l1.update()
UpdateLabel()
root=Tk()
photo = PhotoImage(file="out.png")
l1=Label(root,image=photo,height=100,width=200)
t1=Text(root,height=5,width=50)
b1=Button(root,text="submit",command=verify)
b2=Button(root,text="refresh",command=refresh)
l1.pack()
t1.pack()
b1.pack()
b2.pack()
root.mainloop()