Plaintext password

 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 6 years, 7 months ago
  2. Password Reset Form Newforms by glisha 7 years ago
  3. Send large files through Django, and how to generate Zip files by jcrocholl 6 years, 8 months ago
  4. MySQL django password function by mcosta 4 years, 10 months ago
  5. Saving passwords for other services (semi-)securely in a database by equanimity 5 years, 2 months ago

Comments

(Forgotten your password?)