We are building out data masking framework mainly to mask PIIs. Our scale is pretty large, and masking will be done at ingest time, so we want the masking to be done in a very performant manner. Some of the constraints we have are that we would like the masking to be deterministic and reversible. I have looked at AES encryption to encrypt PII, especially AES SIV, on my macbook, it takes around ~2 milliseconds, which may not be ideal for our scale.
Would be great to hear from the community if there are any alternatives to AES SIV which are faster (and deterministic), or if there are any other alternatives to AES encryption.
Here is my encryption method. I am using the Cryptodome.Cipher AES
def encrypt(key: bytes, text: str) -> str: nonce = None cipher = None encoded_text = text.encode('utf-8') nonce = get_random_bytes(AES.block_size) cipher = AES.new(key, AES.MODE_SIV, nonce=nonce) cipher_text, tag = cipher.encrypt_and_digest(encoded_text) ret_cipher_text = nonce + cipher_text ret_cipher_text = tag + ret_cipher_text return b64encode(ret_cipher_text).decode()
The performance of this encryption ~2 millisecond for a small text.