[Cryptography] How do I tell if a byte sequence repeats?

Sampo Syreeni decoy at iki.fi
Sat Aug 23 09:57:04 EDT 2025


On 2025-08-22, Pierre Abbat wrote:

> How can I measure the period without storing the whole sequence?

If it's in a loop, it will come back to a state which you have seen. So 
choose any state actually visited by the algorithm, note the symbol 
offset where you saw it, and watch when you see it again. If you're 
worried you caught your reference state too early, before the loop, just 
pick a new state and continue. If you sample at exponentially increasing 
intervals, you will eventually catch a loop of any size. The memory cost 
is a single copy of the algorithmic state and a pointer, and the search 
cost boils down to a single, say 64bit, comparison per byte, plus 
very occasionally comparing over the whole of the state.
-- 
Sampo Syreeni, aka decoy - decoy at iki.fi, http://decoy.iki.fi/front
+358-40-3648785, 025E D175 ABE5 027C 9494 EEB0 E090 8BA9 0509 85C2


More information about the cryptography mailing list