Why am I getting "Input too long" error when trying to encrypt or decrypt the data?
Asymmetric (public-key) algorithms operate with relatively small chunks of data. The exact size depends on the key length and other factors. For example, with RSA 1024-bit key the length of data that you can encrypt or decrypt is a bit more than 100 bytes. If you need to encrypt larger block, use the session symmetric key to encrypt the data, then encrypt the session key using the asymmetric algorithm.