- Author:
- yetty
- Posted:
- October 29, 2013
- Language:
- Python
- Version:
- Not specified
- Score:
- 1 (after 1 ratings)
Plaintext password hasher (encoded string: plain$1$mysecretpass).
DANGEROUS!!! Use just if you know what you are doing!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | from collections import OrderedDict
from django.utils.translation import ugettext_noop as _
from django.contrib.auth.hashers import BasePasswordHasher
class PlainTextPasswordHasher(BasePasswordHasher):
algorithm = 'plain'
def salt(self):
return ''
def verify(self, password, encoded):
return self.encode(password) == encoded
def encode(self, password, salt=None):
return "%s$1$%s" % (self.algorithm, password)
def safe_summary(self, encoded):
algorithm, iterations, password = encoded.split('$', 2)
return OrderedDict([
(_('algorithm'), algorithm),
(_('iterations'), iterations),
(_('password'), password),
])
|
More like this
- Template tag - list punctuation for a list of items by shapiromatron 9 months ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 9 months, 1 week ago
- Serializer factory with Django Rest Framework by julio 1 year, 4 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 4 months ago
- Help text hyperlinks by sa2812 1 year, 5 months ago
Comments
Please login first before commenting.