Security is irrelevant in my use case.
However, a low collision probability is a requirement. By low I mean something comparable to the odds of MD5(textA + keyB) = MD5(textC + keyD)
for different texts and keys. Text and key have, say, 16 bytes. The sign +
here means concatenation.
I have been using AES for this task, but it is 100x slower than MD5 in my tests shown below. Of course MD5 is irreversible, so I can't use it.
One important point is that it should also be non-commutative, i.e. encrypt(textA, keyB) != encrypt(keyB, textA)
otherwise I guess I could just use the XOR bit-wise operation.
Any Python library or code implementing the algorithm is welcome.
AES vs MD5 comparison on Intel i7 8th notebook:
In [287]: %timeit aes(n, n)
9.07 µs ± 7.95 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In [288]: %timeit md5(n)
153 ns ± 0.237 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)