In order to against the side channel analysis attack such as power, electromagnetic waves, and time attack, an optimized masking method is proposed for Advanced Encryption Standard (AES) algorithm in this paper. This scheme adopts random hamming distance mask and offset randomization strategy in the first two rounds, the last round and two rounds randomly selected in the middle of the AES algorithm to ensure the security of each intermediate value. The scheme then adopts fixed-value mask strategy in the five rounds in the middle, which can redu...