Any browser encryption for any reason should be done with the SubtleCrypto built-in library, because it uses better entropy generation and is less susceptible to timing-based attacks than third-party libraries can be. You'll want either AES-CBC for private-key encryption or RSA-OAEP for public-key encryption.
This is not a subject I'm going to delve into too deeply in a post, but be prepared for a lot of homework and testing to get everything coordinated. You'll also want a good grasp of character encodings, and you might end up with multiple manual character conversions. I have my doubts as to your intentions (I think you're completely wasting your time, for reasons already mentioned) but I prefer to give answers rather than advice. Have fun!