First thing, since the client-side Javascript needs access to the encryption functionality but not, presumably, the decryption functionality (otherwise why encrypt?) you need to use an asymmetric encryption algorithm. Something like RSA. Alternatively, you could use a cryptographic hash, which is a one-way function. Might help if you gave us some context on what you are trying to achieve, but from the description so far, I suggest you look for implementations of a hash algorithm like one of the SHA-2 family in JavaScript - the System.Cryptography namespace in C# has these already.
If you're implementing some sort of security client-side, beware. If you are, for example, trying to compare a password hash with what's on the server, and you make the comparison on the client side, a malicious user could simply attach a debugger and bypass your logic....