Dammann gratings (DG) have become a powerful tool for generating multi-level spectral points in equal-intensity speckle arrays through binary phase variation. Conventional DGs are limited to regular dot arrays, such as squares and circular rings. The emergence of metasurface-based coding technology opens new avenues for ultra-thin, compact, and miniaturized DGs. In this study, we present a comprehensive exploration of polarization multiplexing DGs employing an alldielectric metasurface. Our work introduces a novel twodimensional (2D) DG optimization algorithm tailored for specific desired array patterns, including non-centrally symmetric arrays and arrays maximizing specific desired orders. This innovation significantly broadens the applications of DGs in irregular arrays.Additionally, in contrast to the numerous dimension sizes generated by conventional Gerchberg-Saxton (GS) algorithms, the proposed method employs a silicon nanorod array with only three distinct sizes. This streamlined approach greatly enhances precision control in nanofabrication and facilitates large-scale industrial replication. Furthermore, the incorporation of polarization multiplexing in DGs enhances their versatility, amplifying both channel capacity and spectrum utilization, and allowing for the secure encoding of private information through polarization states. The utilization of orthogonal polarization states becomes crucial for information reuse and hiding, where independent coding information is applied to orthogonally polarized light, enabling applications such as secure information reuse and hiding. Simultaneously, our method maintains exemplary performance metrics, boasting efficiencies and uniformities of 75% and 77%, respectively. Notably, our approach achieves effective suppression of the 0 th diffraction order intensity, a crucial advancement with substantial implications for practical metasurface optics applications. The proposed method holds great promise across diverse applications, including structured light projection, optical communication, and 3D imaging, paving the way for DG integration into various scientific and technological domains.