The invention discloses a data
encryption / decryption method based on a
racetrack memory, comprising the following steps: dividing a
racetrack memory array into a plurality of
encryption areas with preset size as basic units of
encryption storage, and setting an independent encryption key Shift-key for each encryption area; when a
system is initialized, generating a Shift-key based on a random number for each
storage area as an encryption key of the
storage area, and storing the Shift-keys in a volatile
static random access memory; after the keys are generated, performing shift encryption on each
storage area according to the key; and when data is read or written, performing encryption / decryption on each storage area according to the key. The data encryption / decryption method can better protect data in the
racetrack memory, ensure the security of data and avoid potential safety hazards caused by power failure or physical power stealing of the
system. The invention further discloses a data encryption / decryption
system based on a racetrack memory.