code: def truncate(hmac_result, length=6):
      
      assert(len(hmac_result) == 20)
      offset   =  ord(hmac_result[19]) & 0xf
      bin_code = (ord(hmac_result[offset]) & 0x7f) << 24 \
          | (ord(hmac_result[offset+1]) & 0xff) << 16 \
          | (ord(hmac_result[offset+2]) & 0xff) <<  8 \
          | (ord(hmac_result[offset+3]) & 0xff)
      return bin_code % (10 ** length)
docs: Perform the truncating.