Exemple #1
0
def print_fingerprint(fp:  bytes,    # Contact's fingerprint
                      msg: str = ''  # Title message
                      ) -> None:
    """Print a formatted message and fingerprint inside the box.

    Truncate fingerprint for clean layout with three rows that have
    five groups of five numbers. The resulting fingerprint has
    249.15 bits of entropy which is more than the symmetric security
    of X448.
    """
    p_lst  = [msg, ''] if msg else []
    b10fp  = b10encode(fp)[:(3*5*5)]
    parts  = split_string(b10fp, item_len=(5*5))
    p_lst += [' '.join(split_string(p, item_len=5)) for p in parts]

    m_print(p_lst, box=True)
Exemple #2
0
 def test_b10encode(self):
     self.assertEqual(
         b10encode(FINGERPRINT_LENGTH * b'a'),
         '44046402572626160612103472728795008085361523578694645928734845681441465000289'
     )