re-factor authentication processing and encryption