This application provides a
data processing method and related apparatus. The method includes: generating a random
irreducible polynomial corresponding to a target finite field using a target S-box in a target cryptographic
algorithm; determining multiple linearly independent target elements using each element in the target finite field to form a random basis corresponding to the target finite field; generating a random S-box different from the target S-box using the random
irreducible polynomial and the random basis; sending the random S-box to a
data terminal for subsequent
data processing of the data to be processed based on the target cryptographic
algorithm, changing the target S-box to a random S-box, and obtaining the
data processing result of the data to be processed. Compared with evolutionary algorithms, this method has lower computational complexity, reduces the consumption of computing resources, and lowers the computational load on the processor. Even in data
processing scenarios based on target cryptographic algorithms with limited computing resources, it improves the security of data
processing based on target cryptographic algorithms and ensures message security.