As I have developed my app using openFL which uses haxe, and I am about to start the activation part of my software, I wonder how would I safely store my encryption secret key? would I just hard code it into my app??!
I will be using this key to encrypt data before sending to server, and I will be using it to de-encrypt data received from server too.
Any one can recommend best practices followed in such case?
This sounds like a job for asymmetric encryption.
The server can now decrypt the AES keys using the private key and decrypt the data with the retrieved keys. Then verify the MAC, if you included it in your protocol. Finally decrypt the ciphertext to retrieve the plaintext.
This scheme is called hybrid encryption because it uses both symmetric and asymmetric encryption. Beware of padding oracle attacks (which leak all the plain text to an attacker) if you don't use a MAC. Always verify the MAC before decrypting.
You can store an RSA public key within your application. With this public key you can encrypt an AES key (using PKCS#1 OAEP or v1.5 padding).