def key_CV(key, kcv_length=6):
    """
    Get DES key check value. The key is binary hex e.g. b'DF1267EEDCBA9876'
    """
    cipher = DES3.new(B2raw(key), DES3.MODE_ECB)
    encrypted = raw2B(cipher.encrypt(B2raw(b'00000000000000000000000000000000')))

    return encrypted[:kcv_length]
Get DES key check value. The key is binary hex e.g. b'DF1267EEDCBA9876'