Encrypts data with a given key written in PHP