반응형
반응형

[python] Generate Captcha Using Python

 

 

https://www.geeksforgeeks.org/generate-captcha-using-python/

 

Generate Captcha Using Python - GeeksforGeeks

A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

www.geeksforgeeks.org

 

In this article, we are going to see how to generate a captcha using Python package captcha to generate our own CAPTCHA (Completely Automated Public Turing Test to Tell Computers and Humans Apart) in picture form. CAPTCHA is a form of challenge-response authentication security mechanism. CAPTCHA prevents automated systems from reading the distorted characters in the picture.

Installation:

pip install captcha

Generating image captcha: 

Here we are going to generate an image captcha:

Stepwise implementation:

Step 1: Import module and create an instance of ImageCaptcha().

image = ImageCaptcha(width = 280, height = 90)

Step 2: Create image object with image.generate(CAPTCHA_Text).

data = image.generate(captcha_text)  

Step 3: Save the image to a file image.write().

image.write(captcha_text, 'CAPTCHA.png')

Below is the full implementation:

  • Python3

 

# Import the following modules
from captcha.image import ImageCaptcha
 
# Create an image instance of the given size
image = ImageCaptcha(width = 280, height = 90)
 
# Image captcha text
captcha_text = 'GeeksforGeeks' 
 
# generate the image of the given text
data = image.generate(captcha_text) 
 
# write the image on the given file and save it
image.write(captcha_text, 'CAPTCHA.png')

Output:

Image CAPTCHA

Generating Audio captcha:

Here we are going to generate an audio captcha:

Stepwise implementation:

Step 1: Import module and create an instance of AudioCaptcha().

image = audioCaptcha(width = 280, height = 90)

Step 2: Create an audio object with audio.generate(CAPTCHA_Text).

data = audio.generate(captcha_text)  

Step 3: Save the image to file audio.write().

audio.write(captcha_text, audio_file)

Below is the full implementation:

  • Python3

 

# Import the following modules
from captcha.audio import AudioCaptcha
 
# Create an audio instance
audio = AudioCaptcha() 
 
# Audio captcha text
captcha_text = "5454"
 
# generate the audio of the given text
audio_data = audio.generate(captcha_text)
 
# Give the name of the audio file
audio_file = "audio"+captcha_text+'.wav'
 
# Finally write the audio file and save it
audio.write(captcha_text, audio_file)

Output:

Video Player
 
 
 
00:00
 
00:13
 
 

 

Ready to dive into the future? Mastering Generative AI and ChatGPT is your gateway to the cutting-edge world of AI. Perfect for tech enthusiasts, this course will teach you how to leverage Generative AI and ChatGPT with hands-on, practical lessons. Transform your skills and create innovative AI applications that stand out. Don't miss out on becoming an AI expert – Enroll now and start shaping the future!

반응형
반응형

— 알베르트 아인슈타인

이것은 아인슈타인이 1930년 2월 5일에 아들 에두아르트에게 쓴 편지에서 인용한 것입니다. 그는 아들에게 "인생은 자전거를 타는 것과 같아. 균형을 유지하려면 계속 움직여야 해."라고 격려합니다. Walter Isaacson의 책 Einstein: His Life and Universe (2007) 367쪽에서 발췌

 

This is a quote from a letter that Einstein wrote to his son Eduard, on February 5th 1930. He encourages his son, “Life is like riding a bicycle. To keep your balance you must keep moving.” From the book Einstein: His Life and Universe (2007) p. 367, by Walter Isaacson

 
반응형
반응형

언제나 꽃길을 걷고
이슬만 마시는 게 사랑이 아닙니다.
그런 사랑은 오래 가지 못합니다. 평범한
일상의 삶 속에 잘 녹아든 사랑이어야
오래 갑니다. 가장 '사소한 일'에서도
지축을 흔드는 기쁨을 찾아내며
함께 일구어가는 사랑이
진짜 사랑이고
오래 갑니다.


- 고도원, 박덕은의 《당신이 행복하면 나도 행복하다》 중에서 -


* '우리의 사랑은 영원하다.'
진실한 고백일지라도 지키기는 어렵습니다.
그러나 가능한 일입니다. 영화의 주제가 되곤 하는
생을 뛰어넘는 천년의 사랑은 자신의 기쁨을 추구하는
사랑이 아닙니다. 상대를 위해 목숨을 버리면서까지
지켜주고 싶은 헌신적인 사랑입니다. 그 마음으로
오늘 이 순간에 기쁨으로 사랑하면 천년의 사랑,
영원한 사랑으로 이어질 수 있습니다.

반응형

'아침편지' 카테고리의 다른 글

'내면의 음악'이 들릴 때  (2) 2024.09.25
건강한 장수 비결  (0) 2024.09.24
저항  (0) 2024.09.23
병이 있으니까 운동한다?  (1) 2024.09.23
인생의 축(軸)  (2) 2024.09.23
반응형

더는 못 걷겠다

반응형

'아침편지' 카테고리의 다른 글

건강한 장수 비결  (0) 2024.09.24
천년의 사랑, 영원한 사랑  (0) 2024.09.23
병이 있으니까 운동한다?  (1) 2024.09.23
인생의 축(軸)  (2) 2024.09.23
사슬  (0) 2024.09.14
반응형

병이 있으니
운동한다고 생각하게 되면,
내 잠재의식 속에 병이 자리 잡게 됩니다
아무리 몸에 좋은 운동을 하더라도 병이란
잠재의식이 방해꾼처럼 훼방을 놓아 운동
효과를 쓸모없게 만듭니다. 그러니 운동할
때는 어떤 운동이라도 좋아하는 걸
골라서 하세요. 마음은 놀이나
게임하듯 즐겁게 가지고요.


- 전홍준의 《보디 리셋》 중에서 -


* 병이 있으니 운동을 한다?
그러면 늦습니다. 싫어하는 운동을
억지로 한다? 그것도 옳지 않습니다.
운동은 일이나 노동이 아닙니다. 일과 노동은
고되고 피곤하지만 놀이는 지치지 않고 즐겁습니다.
시간 가는 줄 모르고, 돈을 써가면서 하는 것이
놀이입니다. 운동도 놀이처럼 하면
다가오던 병도 물러납니다.

반응형

'아침편지' 카테고리의 다른 글

천년의 사랑, 영원한 사랑  (0) 2024.09.23
저항  (0) 2024.09.23
인생의 축(軸)  (2) 2024.09.23
사슬  (0) 2024.09.14
위험한 징조, 희망의 징조  (0) 2024.09.13
반응형

축(軸)은
바퀴를 굴리는 중심입니다.
축이 부실하거나 틀어져 있으면
가다가 멈추거나 엉뚱한 방향으로 구릅니다.
5세 이전, 인생 첫 번째 축의 핵심은 '어휘'입니다.
누구에게서 어떤 말을 듣고 새기느냐에 따라
삶의 목표와 방향이 결정됩니다.


- 고도원 박덕은의 《당신이 행복하면 나도 행복하다》 중에서 -  


* 축은 수레의
중심이면서 바퀴를 다스립니다.
축이 견고해야 수레가 힘을 쓸 수 있습니다.
인생의 축은 어린 시절 다져집니다. 특히 '어휘'는
그 모든 것에 앞서는 인생의 축입니다. 엄마 아빠의
어휘력과 독서습관에 따라 아이들의 어휘 실력은
천차만별입니다. 이때 형성된 축이 아이들의
평생을 좌우합니다. 굴곡지고 험난한 길을
고장 없이 잘 굴러갈 수 있습니다.

반응형

'아침편지' 카테고리의 다른 글

저항  (0) 2024.09.23
병이 있으니까 운동한다?  (1) 2024.09.23
사슬  (0) 2024.09.14
위험한 징조, 희망의 징조  (0) 2024.09.13
타인의 존엄성  (0) 2024.09.12

+ Recent posts