Improve encrypt factory.