def pkcs7_pad(plaintext: bytes, block_size: int=0x10) -> bytes:
    """
    Pad a message using the byte padding algorithm described in PKCS#7
    This padding scheme appends n bytes with value n, with n the amount of padding bytes.
    
    The specification describing the padding algorithm can be found here:
    https://tools.ietf.org/html/rfc2315#section-10.3
    """

    assert 0 < block_size < 0x100
    
    # If the plaintext is an exact multiple of block_size, 
    # we need to append a whole block.
    remainder = block_size - (len(plaintext) % block_size)

    return plaintext + bytes([remainder] * remainder)