codekingpro/portable-devtools
114k
1"""2passlib.utils.des - DEPRECATED LOCATION, WILL BE REMOVED IN 2.03 4This has been moved to :mod:`passlib.crypto.des`.5"""6#=============================================================================7# import from new location8#=============================================================================9from warnings import warn10warn("the 'passlib.utils.des' module has been relocated to 'passlib.crypto.des' "11 "as of passlib 1.7, and the old location will be removed in passlib 2.0",12 DeprecationWarning)13 14#=============================================================================15# relocated functions16#=============================================================================17from passlib.utils.decor import deprecated_function18from passlib.crypto.des import expand_des_key, des_encrypt_block, des_encrypt_int_block19 20expand_des_key = deprecated_function(deprecated="1.7", removed="1.8",21 replacement="passlib.crypto.des.expand_des_key")(expand_des_key)22 23des_encrypt_block = deprecated_function(deprecated="1.7", removed="1.8",24 replacement="passlib.crypto.des.des_encrypt_block")(des_encrypt_block)25 26des_encrypt_int_block = deprecated_function(deprecated="1.7", removed="1.8",27 replacement="passlib.crypto.des.des_encrypt_int_block")(des_encrypt_int_block)28 29#=============================================================================30# deprecated functions -- not carried over to passlib.crypto.des31#=============================================================================32import struct33_unpack_uint64 = struct.Struct(">Q").unpack34 35@deprecated_function(deprecated="1.6", removed="1.8",36 replacement="passlib.crypto.des.des_encrypt_int_block()")37def mdes_encrypt_int_block(key, input, salt=0, rounds=1): # pragma: no cover -- deprecated & unused38 if isinstance(key, bytes):39 if len(key) == 7:40 key = expand_des_key(key)41 key = _unpack_uint64(key)[0]42 return des_encrypt_int_block(key, input, salt, rounds)43 44#=============================================================================45# eof46#=============================================================================47 