Only tr once we've set the encoding to BINARY

String#tr fails if the input string contains invalid Unicode
characters. This is fine, but only if the string realizes that it's
binary data rather than Unicode encoded characters. So we force it to
binary mode *before* we String#tr.

The String#dup doesn't actually duplicate the string's contents, or we'd
worry about making a copy of the potentially-sensitive data in
memory. This isn't an issue for the exact reason we're doing String#tr
in the first place: Ruby is smart enough to copy-on-write the memory
used for the String.