sentry.hashers.mysql – sentry.hashers.mysql module reference

MySQL-compatible password hashers

class sentry.hashers.mysql.MySQLCompatHasher

Bases: sentry.hashers.mysql.MySQLHasher A hasher that can validate new and old style mysql passwords. hsh() will generate new style passwords

>>> h = MySQLCompatHasher()
>>> h("70de51425df9d787", "hello")
True
>>> h("*6B4F89A54E2D27ECD7E8DA05B4AB8FD9D1D8B119", "hello")
True
>>> h.hsh("hello")
'*6B4F89A54E2D27ECD7E8DA05B4AB8FD9D1D8B119'
class sentry.hashers.mysql.MySQLHasher

Bases: sentry.hashers.BaseHasher A hasher that mimic’s MySQL’s PASSWORD() function in versions >= 4.0

>>> h = MySQLHasher()
>>> h("*6B4F89A54E2D27ECD7E8DA05B4AB8FD9D1D8B119", "hello")
True
>>> h("*70BB17D9634310906050FED37E38259FFAE578B8", "hello")
False
hsh(clear)
>>> h = MySQLHasher()
>>> h.hsh("hello")
'*6B4F89A54E2D27ECD7E8DA05B4AB8FD9D1D8B119'
class sentry.hashers.mysql.MySQLOldHasher

Bases: sentry.hashers.BaseHasher A hasher that mimic’s MySQL’s PASSWORD() function in versions < 4.0, or the OLD_PASSWORD() function in versions >= 4.0

>>> h = MySQLOldHasher()
>>> h("70de51425df9d787", "hello")
True
>>> h("2140d09276f9a814", "hello")
False
hsh(clear)
>>> h = MySQLOldHasher()
>>> h.hsh("hello")
'70de51425df9d787'
>>> h.hsh(" ")
'5030573512345671'
>>> h.hsh("  ")
'5030573512345671'
>>> h.hsh("hello world")
'6c755a9e66debe8a'
>>> h.hsh("helloworld")
'6c755a9e66debe8a'
>>> h.hsh("really super long password with Extra stuff!")
'4801a7aa4dea6bda'