A swift middleware for encrypting object