1234567891011121314151617181920212223 |
- def _raw_bsdi_crypt(secret, rounds, salt):
- """pure-python backend for bsdi_crypt"""
- # decode salt
- salt_value = h64.decode_int24(salt)
- # gotta do something - no official policy since this predates unicode
- if isinstance(secret, unicode):
- secret = secret.encode("utf-8")
- assert isinstance(secret, bytes)
- # forbidding NULL char because underlying crypt() rejects them too.
- if _BNULL in secret:
- raise uh.exc.NullPasswordError(bsdi_crypt)
- # convert secret string into an integer
- key_value = _bsdi_secret_to_key(secret)
- # run data through des using input of 0
- result = des_encrypt_int_block(key_value, 0, salt_value, rounds)
- # run h64 encode on result
- return h64big.encode_int64(result)
|