Crc64Result.high_bytes()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
dl 0
loc 6
rs 9.4285
1
"""Implements the Crc64Result class.
2
"""
3
4
5
from __future__ import unicode_literals
6
7
8
class Crc64Result(object):
9
    """Implements a class that represents the result of a 64-bit Cyclic Redundancy Check checksum.
10
    """
11
12
    def __init__(self, crc64):
13
        self._crc64 = crc64
14
15
16
    @property
17
    def high_bytes(self):
18
        """Returns the topmost 4 bytes of the checksum formatted as a lowercase hex string.
19
        """
20
21
        return format(self._crc64 >> 32, "08x")
22
23
24
    @property
25
    def low_bytes(self):
26
        """Returns the bottommost 4 bytes of the checksum formatted as a lowercase hex string.
27
        """
28
29
        return format(self._crc64 & 0xffffffff, "08x")
30
31
32
    def __eq__(self, other):
33
        return self._crc64 == other._crc64 # pylint: disable=locally-disabled, protected-access
34
35
36
    def __ne__(self, other):
37
        return not self.__eq__(other)
38
39
40
    def __str__(self):
41
        return format(self._crc64, "016x")
42