12345678910111213141516 |
- def raw(cls, secret, user):
- """encode password using msdcc v2 algorithm
- :type secret: unicode or utf-8 bytes
- :arg secret: secret
- :type user: str
- :arg user: username to use as salt
- :returns: returns string of raw bytes
- """
- from passlib.crypto.digest import pbkdf2_hmac
- secret = to_unicode(secret, "utf-8", param="secret").encode("utf-16-le")
- user = to_unicode(user, "utf-8", param="user").lower().encode("utf-16-le")
- tmp = md4(md4(secret).digest() + user).digest()
- return pbkdf2_hmac("sha1", tmp, user, 10240, 16)
|