Metadata-Version: 2.1
Name: django-plaintext-password
Version: 0.3.0
Summary: A Django password hasher to store passwords in plaintext.
Author: Jake Howard
License: MIT License
        
        Copyright (c) 2020 Jake Howard
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Source, https://github.com/RealOrangeOne/django-plaintext-password
Project-URL: Issues, https://github.com/RealOrangeOne/django-plaintext-password/issues
Project-URL: Changelog, https://github.com/RealOrangeOne/django-plaintext-password/releases
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django>=4.2

# django-plaintext-password

![CI](https://github.com/RealOrangeOne/django-plaintext-password/workflows/CI/badge.svg)
![PyPI](https://img.shields.io/pypi/v/django-plaintext-password.svg)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-plaintext-password.svg)
![PyPI - Wheel](https://img.shields.io/pypi/wheel/django-plaintext-password.svg)
![PyPI - Status](https://img.shields.io/pypi/status/django-plaintext-password.svg)
![PyPI - License](https://img.shields.io/pypi/l/django-plaintext-password.svg)

A Django password hasher to store passwords in plaintext.

This hasher is over 100000x faster than Django's default hasher, and around 20x faster than the MD5-based hasher.

## Installation and usage

```
pip install django-plaintext-password
```

Then add `plaintext_password.PlaintextPasswordHasher` to [`PASSWORD_HASHERS`](https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-PASSWORD_HASHERS) in `settings.py`. To ensure it's used by default, make it the first or only item.

## How does it work?

By default, Django will store the password `password123` in a format similar to:

```
pbkdf2_sha256$216000$gd57n4OWJrXh$Xs/TqhwJICOxsLONGlKXorjuWccooiuJmJOUaxbwcOQ=
```

This is good for security as the password has been both salted and hashed before being saved into the database, making it almost impossible to retrieve the original password. This library however, stores the password as-is:

```
plaintext$$password123
```

This makes searching by password possible, as well as comparing users passwords and allowing you to email users their passwords if they forget them - neat!

In addition to storing the values directly in the database for easy retrieval, the comparison is done simply with `==`, rather than using [`secrets.compare_digest`](https://docs.python.org/3/library/secrets.html#secrets.compare_digest).

## _"Should I use this in production?"_

Oh definitely not. Storing passwords in plaintext is a very *very* bad thing. Django's defaults are incredibly secure and should be used unless you have a good reason not to.

For more on why using this in production is a terrible idea, check out [How to store passwords](https://theorangeone.net/posts/how-to-store-passwords/).

When running deployment checks, this will throw a "CRITICAL" error if in use.

## Why?

Well, why not?

Although in all seriousness, If as part of your tests you're creating a large number of users, or just a couple users but you've got a lot of tests, you can get quite a performance improvement by simplifying the password hasher.

Unfortunately due to a limitation (and feature) with Django, it's not possible to store just the value directly, it must be prefixed with the algorithm.
