def _calculate_verification_code(hash: bytes) -> int:
    """
    Verification code is a 4-digit number used in mobile authentication and mobile signing linked with the hash value to be signed.
    See https://github.com/SK-EID/MID#241-verification-code-calculation-algorithm
    """
    return ((0xFC & hash[0]) << 5) | (hash[-1] & 0x7F)