This OCaml code implements produces the Spritz cipher key stream. It produces the test vectors results given there.

Calling rS creates a new cipher stream, or sponge in the idiom used there. The argument to rS is the ASCII text initialization for the stream. rS returns a record of functions which close over the cipher stream state. Just now only two functions come back; nb of type unit −> int which produces successive elements of the key stream, and squeeze n which produces as a string, the next n elements in a stream. I plan to add functions to provide the other functions described in the paper.