<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_password(reference, attempt):
 """ Compare a reference password with the user attempt. True True False False True True """

    if reference.startswith(u'{PLAIN}'):
        if reference[7:] == attempt:
            return True
    elif reference.startswith(u'{SSHA}'):
        # In python3 b64decode takes inputtype as bytes as opposed to str in python 2, and returns
        # binascii.Error as opposed to TypeError
        if six.PY3:  # pragma: no cover
            try:
                if isinstance(reference, six.text_type):
                    ref = b64decode(reference[6:].encode('utf-8'))
                else:
                    ref = b64decode(reference[6:])
            except binascii.Error:
                return False  # Not Base64
        else:  # pragma: no cover
            try:
                ref = b64decode(reference[6:])
            except TypeError:
                return False  # Not Base64
        if isinstance(attempt, six.text_type):
            attempt = attempt.encode('utf-8')
        salt = ref[20:]
        b64_encoded = b64encode(hashlib.sha1(attempt + salt).digest() + salt)
        if six.PY3:  # pragma: no cover
            # type(b64_encoded) is bytes and can't be compared with type(reference) which is str
            compare = six.text_type('{SSHA}%s' % b64_encoded.decode('utf-8') if type(b64_encoded) is bytes else b64_encoded)
        else:  # pragma: no cover
            compare = six.text_type('{SSHA}%s' % b64_encoded)
        return compare == reference
    elif reference.startswith(u'{BCRYPT}'):
        # bcrypt.hashpw() accepts either a unicode encoded string or the basic string (python 2)
        if isinstance(attempt, six.text_type) or isinstance(reference, six.text_type):
            attempt = attempt.encode('utf-8')
            reference = reference.encode('utf-8')
        if six.PY3:  # pragma: no cover
            return bcrypt.hashpw(attempt, reference[8:]) == reference[8:]
        else:  # pragma: no cover
            return bcrypt.hashpw(
                attempt.encode('utf-8') if isinstance(attempt, six.text_type) else attempt,
                str(reference[8:])) == reference[8:]
    return False