Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
DisCapTy is a highly type hinted Python module to generate Captcha images without struggling your mind on how to make your own. Everyone can use it!
Documentation: https://discapty.readthedocs.io/
DisCapTy is available on PyPi!
pip3 install discapty
To use DisCapTy, you need a Python version equal or greater to 3.7
and below 3.11
.
This project is dependant of Poetry, a dependency management tool. You are most likely going to require this tool to correctly interact with the project & its dependencies, check out Poetry's documentation for how to install it.
To clone the repository: git clone https://github.com/Predeactor/DisCapTy.git
To install dependencies: poetry install
To run tests: poetry run python -m unittest
For DisCapTy, a Captcha is simply a code with any possible objects that can be returned, for example, it is one code (Like "12345") with an image (Usually a PIL.Image.Image
object)
This is because DisCapTy uses the concept of generators that are used to generate a captcha from a given code, and it can return anything.
DisCapTy comes with 3 builtin generators:
import discapty
def generate_a_captcha(initial_input: str) -> discapty.Captcha:
# This generator returns an obfuscated text.
captcha_for_user = discapty.TextGenerator().generate(initial_input)
# Create a Captcha object, the first argument is the clear code, the second is the obfuscated code. Anything goes.
return discapty.Captcha(initial_input, captcha_for_user)
# Generate your Captcha.
captcha = generate_a_captcha("12345")
# Show the obfuscated code. See https://discapty.readthedocs.io for more information on this object.
show_captcha_to_user(captcha.captcha)
import discapty
# Generate your Captcha.
captcha: discapty.Captcha = generate_a_captcha("12345")
# This is your user's input here
user_input: str = '12345'
if captcha.check(user_input) is True:
# The user input is correct
print("Correct!")
else:
# The user input is incorrect
print("Incorrect!")
What's great with the .check
method is that you can specify if you need to remove space in the user's input and/or check casing.
Creating Captcha manually is not a recommended way, because DisCapTy comes with its opinionated challenge runner & is inefficient anyway.
import discapty
challenge = discapty.Challenge(discapty.TextGenerator(), retries=3)
captcha = challenge.begin()
# We cannot provide typehint here, `captcha` is a `typing.Any` and cannot help you, it'll be your
# job to know what you'll get as a captcha.
send_captcha_to_user(captcha)
user_input: str = get_user_input()
is_correct: bool = challenge.check(user_input)
# If the user's input is correct, the challenge ends, if not, `challenge.attempted_tries` will get
# +1, and if it is greater than the retries that has been set, then an error is raised when using
# `.check`
Please see the documentation for more information on how the library work.
You can join my Discord server for any help: https://discord.gg/WdcFUH7ths
DisCapTy is an open-source project distributed under the MIT license:
DisCapTy uses the Roboto font as default font. This font is licensed under Apache-2.0.
FAQs
DisCapTy help you generate obfuscated images, leaving your code easy.
We found that discapty demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.