I don't understand the UX you have in mind, just do it like SSH used to do, a non-echo input field?
I may have misstated the problem above. What I really need to ensure is that a malicious output can't say "the digest is abc123" and trick the user into pasting that into the other program (when the real digest is def456).
Hmm...
Isn't there a public key based way to avoid needing the user to do this.