I guess you mean browser as client in this case ?
I use cryptojs to convert passwords and usernames so I don't know what they actually are before submitting them to my server. But I just did it because I was curious.
What are you trying to accomplish ? do you just want to have an encrypted transmission ? and no clue what's transmitted you can use cryptojs. (anonymous logins and such where the user still uses his password and emails) (hashing)
or you can use this as a security hash to verify the data was not altered during the transmission.
But as soon as you're talking about something like client to client communication a SSL certificate and a P2P connection should do the trick https://webrtc.org/
if you wanna store and reuse code maybe http://bitwiseshiftleft.github.io/sjcl/ does the trick.
You need to be more specific what you want. I just randomly assume usecases because you mentioned cryptojs.
Maybe you're talking about swift and android which changes the whole game because you have control over the client :)