#NEWLINE# def crc_file_update( alg , register , check_bytes ) : #NEWLINE# #INDENT# '\n    Update the CRC using the bit-by-bit-fast CRC algorithm.\n    ' #NEWLINE# if isinstance ( check_bytes , str ) : #NEWLINE# #INDENT# check_bytes = bytearray ( check_bytes , 'utf_8' ) #NEWLINE# #UNINDENT# for octet in check_bytes : #NEWLINE# #INDENT# if alg . reflect_in : #NEWLINE# #INDENT# octet = alg . reflect ( octet , 8 ) #NEWLINE# #UNINDENT# for j in range ( 8 ) : #NEWLINE# #INDENT# bit = ( register & alg . msb_mask ) #NEWLINE# register <<= 1 #NEWLINE# if ( octet & ( 128 >> j ) ) : #NEWLINE# #INDENT# bit ^= alg . msb_mask #NEWLINE# #UNINDENT# if bit : #NEWLINE# #INDENT# register ^= alg . poly #NEWLINE# #UNINDENT# #UNINDENT# register &= alg . mask #NEWLINE# #UNINDENT# return register