diff --git a/projects/Captcha_Genrator/Captcha_Genrator.py b/projects/Captcha_Genrator/Captcha_Genrator.py new file mode 100644 index 000000000..1b07c9c07 --- /dev/null +++ b/projects/Captcha_Genrator/Captcha_Genrator.py @@ -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() + + + diff --git a/projects/Captcha_Genrator/README.md b/projects/Captcha_Genrator/README.md new file mode 100644 index 000000000..86e94e42e --- /dev/null +++ b/projects/Captcha_Genrator/README.md @@ -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=['/ChelseaMarketsr.ttf', '/DejaVuSanssr.ttf'])``` + +### Screenshot +![image](https://user-images.githubusercontent.com/39544459/137623915-1e837ada-f199-4513-a15d-ecbb969fd53e.png) + +## *Mayur Singal* diff --git a/projects/Captcha_Genrator/fonts/ChelseaMarketsr.ttf b/projects/Captcha_Genrator/fonts/ChelseaMarketsr.ttf new file mode 100644 index 000000000..0885a2309 Binary files /dev/null and b/projects/Captcha_Genrator/fonts/ChelseaMarketsr.ttf differ diff --git a/projects/Captcha_Genrator/fonts/DejaVuSanssr.ttf b/projects/Captcha_Genrator/fonts/DejaVuSanssr.ttf new file mode 100644 index 000000000..9d40c3256 Binary files /dev/null and b/projects/Captcha_Genrator/fonts/DejaVuSanssr.ttf differ diff --git a/projects/Captcha_Genrator/requirements.txt b/projects/Captcha_Genrator/requirements.txt new file mode 100644 index 000000000..604852d8a --- /dev/null +++ b/projects/Captcha_Genrator/requirements.txt @@ -0,0 +1 @@ +captcha \ No newline at end of file