windows_13.py 611 B

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