A method of writing data from a first cache to a second cache, comprising: identifying a memory address of the data; obtaining a nonce; generating a keystream using at least a first key, the nonce, and the identified memory address; encrypting, using the generated keystream, the data corresponding to the memory address while being written from the first cache to the second cache, wherein the first cache is local to one of a plurality of processing cores (305, 310) on a central processing unit, CPU, and wherein the second cache forms part of the CPU and is shared by the plurality of processing cores; characterized by: writing the nonce to the second cache together with the encrypted data; the method further comprising, in response to a cache flush occurring: flushing the encrypted data corresponding to the memory address to a memory; and writing the nonce to the memory along with the encrypted data; and wherein the method further comprises, when performing a subsequent read of the encrypted data from the memory: first, retrieving the nonce from the memory; and subsequently reading the encrypted data from the memory while a first portion of the keystream is being computed using the retrieved nonce, for use in decrypting the encrypted data. identifying a memory address of the data; obtaining a nonce; generating a keystream using at least a first key, the nonce, and the identified memory address; encrypting, using the generated keystream, the data corresponding to the memory address while being written from the first cache to the second cache, wherein the first cache is local to one of a plurality of processing cores (305, 310) on a central processing unit, CPU, and wherein the second cache forms part of the CPU and is shared by the plurality of processing cores; characterized by: writing the nonce to the second cache together with the encrypted data; the method further comprising, in response to a cache flush occurring: flushing the encrypted data corresponding to the memory address to a memory; and writing the nonce to the memory along with the encrypted data; and wherein the method further comprises, when performing a subsequent read of the encrypted data from the memory: first, retrieving the nonce from the memory; and subsequently reading the encrypted data from the memory while a first portion of the keystream is being computed using the retrieved nonce, for use in decrypting the encrypted data. writing the nonce to the second cache together with the encrypted data; the method further comprising, in response to a cache flush occurring: flushing the encrypted data corresponding to the memory address to a memory; and writing the nonce to the memory along with the encrypted data; and wherein the method further comprises, when performing a subsequent read of the encrypted data from the memory: first, retrieving the nonce from the memory; and subsequently reading the encrypted data from the memory while a first portion of the keystream is being computed using the retrieved nonce, for use in decrypting the encrypted data. first, retrieving the nonce from the memory; and subsequently reading the encrypted data from the memory while a first portion of the keystream is being computed using the retrieved nonce, for use in decrypting the encrypted data.