You can encrypt messages published via PubNub using AES-256. Applying AES-256 encryption to the contents of all published messages only requires supplying a value to the cipher key parameter.
For more information, check Connection & Message encryption.