Ok, I will add some more comments in line.  Basically, we don't have mask/unmask anymore.  We break the string into an array of chunks and regular strings.  (may be easier to make a plain string into a chunk too ...)

Chunks respond to to_s and as_json to support serialization.