Implemented encrypt function