def encode(s_plaintext: str, bit_length: int) -> list[int]:
    """Encodes bytes to integers mod p.
    Example
    if n = 24, k = n / 8 = 3
    z[0] = (summation from i = 0 to i = k)m[i]*(2^(8*i))
    where m[i] is the ith message byte

    Args:
        s_plaintext: String text to be encoded
        bit_length: bit length of the prime number

    Returns:
        A list of encoded integers
    """
    byte_array = bytearray(s_plaintext, 'utf-16')

    # z is the array of integers mod p
    z = []

    # each encoded integer will be a linear combination of k message bytes
    # k must be the number of bits in the prime divided by 8 because each
    # message byte is 8 bits long
    k = bit_length // 8

    # j marks the jth encoded integer
    # j will start at 0 but make it -k because j will be incremented during first iteration
    j = -1 * k
    # num is the summation of the message bytes
    # num = 0
    # i iterates through byte array
    for idx in range(len(byte_array)):
        # if i is divisible by k, start a new encoded integer
        if idx % k == 0:
            j += k
            # num = 0
            z.append(0)
        # add the byte multiplied by 2 raised to a multiple of 8
        z[j // k] += byte_array[idx] * (2 ** (8 * (idx % k)))

    return z