How to encypt/decrypt messages after ECDH key agreement I am using Diffie-Helman key exchange to generate the shared secret. But how will can a message be encrypted using this shared key?
You can't encrypt a message with ECDH alone, because all it gives you is a shared secret that you can't really control. Rather, you use that secret in a symmetric scheme like AES (generally after passing it through a KBKDF to convert from an ECDH result to a proper-length and less-structured symmetric key, which you then use as the key for symmetric crypto).