Encryption rewriting