Login

Plaintext password

Author:
yetty
Posted:
October 29, 2013
Language:
Python
Version:
Not specified
Tags:
password hashes plaintext
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

  1. Trigger a user password change by jedie 7 years, 7 months ago
  2. Password Reset Form Newforms by glisha 7 years, 11 months ago
  3. Send large files through Django, and how to generate Zip files by jcrocholl 7 years, 7 months ago
  4. MySQL django password function by mcosta 5 years, 10 months ago
  5. Saving passwords for other services (semi-)securely in a database by equanimity 6 years, 1 month ago

Comments

Please login first before commenting.