import hashlib
import binascii


def hash_rabbitmq_password(password: str, salt: str) -> str:
    """
    Hashes (sha256) the provided password according to the RabbitMQ algorithm

    :param salt: a 32bit string in hex, i.e. e7663f87
    :param password: any string
    :return: the hashed password
    """
    salt_and_password = salt + password.encode('utf-8').hex()

    salt_and_password_bytes = bytearray.fromhex(salt_and_password)

    salted_sha256 = hashlib.sha256(salt_and_password_bytes).hexdigest()

    password_hash = bytearray.fromhex(salt + salted_sha256)

    result = binascii.b2a_base64(password_hash).strip().decode('utf-8')

    return result