encrypt password and write to db