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

Added Captcha Generator #491

Merged
merged 7 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions projects/Captcha_Genrator/Captcha_Genrator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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()



14 changes: 14 additions & 0 deletions projects/Captcha_Genrator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Captcha Genrator
A simple image captcha genrator

### Prerequisites
1. Install the dependencies by executing the following command
```pip install -r requirements.txt```

2. Update the path of font in code (if required)
```image = ImageCaptcha(fonts=['<path>/ChelseaMarketsr.ttf', '<path>/DejaVuSanssr.ttf'])```

### Screenshot
![image](https://user-images.githubusercontent.com/39544459/137623915-1e837ada-f199-4513-a15d-ecbb969fd53e.png)

## *Mayur Singal*
Binary file not shown.
Binary file added projects/Captcha_Genrator/fonts/DejaVuSanssr.ttf
Binary file not shown.
1 change: 1 addition & 0 deletions projects/Captcha_Genrator/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
captcha