[Zope-Checkins] CVS: Zope/lib/python/AccessControl - AuthEncoding.py:1.8
Chris Withers
chrisw@nipltd.com
Mon, 6 Jan 2003 10:05:26 -0500
Update of /cvs-repository/Zope/lib/python/AccessControl
In directory cvs.zope.org:/tmp/cvs-serv26719/lib/python/AccessControl
Modified Files:
AuthEncoding.py
Log Message:
Collector #435: Support for passwords encoded using MySQL's
PASSWORD() function add to lib/python/AccessControl/AuthEncoding.py.
=== Zope/lib/python/AccessControl/AuthEncoding.py 1.7 => 1.8 ===
--- Zope/lib/python/AccessControl/AuthEncoding.py:1.7 Wed Aug 14 17:29:07 2002
+++ Zope/lib/python/AccessControl/AuthEncoding.py Mon Jan 6 10:05:23 2003
@@ -121,6 +121,29 @@
registerScheme('CRYPT', CryptDigestScheme())
+class MySQLDigestScheme:
+
+ def encrypt(self, pw):
+ nr = 1345345333L
+ add = 7
+ nr2 = 0x12345671L
+ for i in pw:
+ if i == ' ' or i == '\t':
+ continue
+ nr ^= (((nr & 63) add) * ord(i)) + (nr << 8)
+ nr2 += (nr2 << 8) ^ nr
+ add += ord(i)
+ r0 = nr & ((1L << 31) - 1L)
+ r1 = nr2 & ((1L << 31) - 1L)
+ return "%08lx%08lx" % (r0, r1)
+
+ def validate(self, reference, attempt):
+ a = self.encrypt(attempt)
+ return (a == reference)
+
+registerScheme('MYSQL', MySQLDigestScheme())
+
+
def pw_validate(reference, attempt):
"""Validate the provided password string, which uses LDAP-style encoding
notation. Reference is the correct password, attempt is clear text