refactor password encryption