[First post to list, hello everyone!]

Hi,

I'm failing to find a solution to an issue that seems fairly commonplace
to me, so I'm assuming it's been answered before and I failed to dig up
the answer (I tried). So feel free to alert me to any resources where
this type of question has previously been answered.

I'm currently trying to figure out a way to store a password hash in a
table, allowing the password to be passed in in plain. I'd prefer to use
a built-in password hashing functions on connections that support them,
like so:

from sqlobject import *
from Crypto.Hash import SHA256
class Credential(SQLObject):
    username = StringCol(unique=True, alternateID=True)
    password = StringCol()
    def _set_password(self, newpass):
        try:
            # FIXME: update field with hash generated
            # from PASSWORD(newpass)
        except dberrors.OperationalError:
            # assume internal password function is
            # not available, do my own hashing
            hash = SHA256.new(newpass).hexdigest()
            self._SO_set_password(hash)

So the "do my own hashing" part is easily achieved. It's the use of the
internal password function that's baffling me. I'd like to use
PASSWORD() on MySQL, and I believe this should work for MS SQL Server
too as it also appears to have a built-in password hashing function.

Is there a way to achieve this, combining _SO_set_* and
sqlbuilder.func.PASSWORD perhaps? If so, how would I do that?

Grateful for any insights. Thanks much in advance.

Cheers,
Florian



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to