Encryption to login added

some minor refactoring