<s> from __future__ import absolute_import , division , print_function <EOL> import six <EOL> def _truncate_digest ( digest , order_bits ) : <EOL> digest_len = len ( digest ) <EOL> if <NUM_LIT:8> * digest_len > order_bits : <EOL> digest_len = ( order_bits + <NUM_LIT:7> ) // <NUM_LIT:8> <EOL> digest = digest [ : digest_len ] <EOL> if <NUM_LIT:8> * digest_len > order_bits : <EOL> rshift = <NUM_LIT:8> - ( order_bits & <NUM_LIT> ) <EOL> assert <NUM_LIT:0> < rshift < <NUM_LIT:8> <EOL> mask = <NUM_LIT> >> rshift << rshift <EOL> digest = digest [ : - <NUM_LIT:1> ] + six . int2byte ( six . indexbytes ( digest , - <NUM_LIT:1> ) & mask ) <EOL> return digest </s>
