# Encryption algorithm which produces comparable results for substrings

I am wondering is there any encryption algorithm available which produces comparable string.

I am expecting the output as shown below.

Data        |       output
---------------------------------------------
testData    |  uTrildHcKpM
testData_1  |  uTrildHcKpMiopu


Please let me know if you happen to know such algorithms.

• Do you want order-preserving encryption, or prefix-preserving one, or both? – Paŭlo Ebermann Oct 11 '12 at 17:48
• I am not sure what is search order-preserving encryption and prefix-preserving. Could you plese let me know about it? – Narendra Oct 11 '12 at 21:13
• If I understand your desired property correctly, then the inherent weaknesses of that property lead to far too weak encryption. – CodesInChaos Oct 11 '12 at 21:46
• In particular, I suspect it's possible to show that the only kind of cipher that offers this property is a substitution cipher that works on single characters. – CodesInChaos Oct 11 '12 at 21:46
• @Narendra: order preserving means $a < b \Rightarrow E(a) < E(b)$, for some (natural) ordering on the plaintexts and ciphertexts. Prefix preserving means that $E(ab) = E(a)x$ for some $x$. – Paŭlo Ebermann Oct 12 '12 at 8:03