~ubuntu-branches/ubuntu/vivid/trac-accountmanager/vivid

« back to all changes in this revision

Viewing changes to acct_mgr/md5crypt.py

  • Committer: Bazaar Package Importer
  • Author(s): Leo Costela
  • Date: 2009-09-21 00:14:57 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090921001457-1r4f8tjyryoqpc1e
Tags: 0.2.1+r5836-1
* new upstream checkout
* debian/changelog: change versioning scheme to use SVN revision 
  instead of date; makes the watch file possible
* debian/watch: added
* debian/README.source: added to explain the strange versioning scheme
* debian/control:
  - bump policy to 3.8.3 (no changes)
  - change hard-coded dep: python-setuptools -> python-pkg-resources
    (closes: #546423)

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
# This port adds no further stipulations.  I forfeit any copyright interest.
13
13
 
14
 
import md5
 
14
from hashlib_compat import md5
15
15
 
16
16
def md5crypt(password, salt, magic='$1$'):
17
17
    # /* The password first, since that is what is most unknown */ /* Then our magic string */ /* Then the raw salt */
18
 
    m = md5.new()
 
18
    m = md5()
19
19
    m.update(password + magic + salt)
20
20
 
21
21
    # /* Then just as many characters of the MD5(pw,salt,pw) */
22
 
    mixin = md5.md5(password + salt + password).digest()
 
22
    mixin = md5(password + salt + password).digest()
23
23
    for i in range(0, len(password)):
24
24
        m.update(mixin[i % 16])
25
25
 
37
37
 
38
38
    # /* and now, just to make sure things don't run too fast */
39
39
    for i in range(1000):
40
 
        m2 = md5.md5()
 
40
        m2 = md5()
41
41
        if i & 1:
42
42
            m2.update(password)
43
43
        else: