Function scrub_open_end
pub fn scrub_open_end(
text: &str,
scrub: impl Fn(&str) -> String,
margin: usize,
) -> StringExpand description
text, which is only the first part of a longer output, scrubbed with scrub and cut back
so that no part of a secret is left at its end.
The end of such a text may be the first half of a secret that scrub cannot recognise, and the
scrubbed length says nothing about where in the raw text a cut falls (a replacement is shorter or
longer than its value). So the text is scrubbed whole, and again without its last margin bytes:
what the two agree on is the text up to the first place where a secret straddles the new end,
which is replaced in the one and cut in the other. margin is the length of the longest value
scrub replaces, derived forms included, and at least SCRUB_OVERLAP: a caller that holds a
longer value must say so, because a value longer than the margin can be kept in part. Where the
two diverge the agreement is backed off a little (a secret that starts like the replacement
agrees with it for a few bytes). The result is scrubbed.