If you use something random enough like a GUID there shouldn’t be any need to hunt through the payload to check for an alias of the boundary. Something like:-
—-=NextPart_3676416B-9AD6-440C-B3C8-FC66DDC7DB45
Header:….
Payload
—-=NextPart_3676416B-9AD6-440C-B3C8-FC66DDC7DB45–