optimize encrypt