Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.

Commit a51bac4

Browse files
authored
Merge pull request #491 from ulixius9/master
Added Captcha Generator
2 parents 1c23249 + 6fdcdff commit a51bac4

File tree

5 files changed

+71
-0
lines changed

5 files changed

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

projects/Captcha_Genrator/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Captcha Genrator
2+
A simple image captcha genrator
3+
4+
### Prerequisites
5+
1. Install the dependencies by executing the following command
6+
```pip install -r requirements.txt```
7+
8+
2. Update the path of font in code (if required)
9+
```image = ImageCaptcha(fonts=['<path>/ChelseaMarketsr.ttf', '<path>/DejaVuSanssr.ttf'])```
10+
11+
### Screenshot
12+
![image](https://user-images.githubusercontent.com/39544459/137623915-1e837ada-f199-4513-a15d-ecbb969fd53e.png)
13+
14+
## *Mayur Singal*
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
captcha

0 commit comments

Comments
 (0)