4 ms·
Encryption is much, much faster than you think. In my carefully-optimised Rust implementation of my scheme (see another comment in this thread) that uses a vari
by chrismorgan 4y ago
Encryption is much, much faster than you think. In my carefully-optimised Rust implementation of my scheme (see another comment in this thread) that uses a variant of Speck128 for encryption, and simple base-conversion into a 20-character array (no allocations!), the base conversion takes takes 100× as long as the encryption, which, in large batches, takes two cycles. Now AES (the topic here) is slower than Speck (which is one of the very fastest “real encryption” schemes out there), so the base-conversion wouldn’t be as much slowerer (certainly nowhere near 100×), but it still goes to show something.
I would not expect you to be able to even measure the difference on general workloads. On massive batch workloads, I think there’s a good chance that the encryption approach with my scheme at least (AES would be a little more iffy) and a 64-bit ID would be just a teensy bit faster than a UUID primary key because of dealing with less data in the database, network and app before the encryption is done—in fact, assuming equivalent stringification I have decided to confidently assert my scheme would be faster, since the only thing that can slow it down is the added encryption code and round keys, which at scale are negligible, and my scheme will save around 60 cycles on stringification due to needing only 20 characters rather than 26. (And you could reduce it another six characters and sixty cycles if you limited it further to 70-bit IDs.) But even there I think you’d be straining to measure it.
- preseinger 4y agoAnd how do you manage maintenance like key rotation, etc?