secrets
secrets copied to clipboard
How do I handle Strings combined with Secret(Box)?
Hey!
Your examples mostly showcase usage with raw bytes. Could you help me out on working with a String that I want to securely store inside one of the Secret variants? The String is read from the tty (it's a user-entered password).
The SecretBox documentation showcases an example where some bytes are moved into SecretVec by using the from method. Is that currently the only way to accomplish this?
Thanks for helping me out!
std::io::Stdin implments the Read trait, so you can read raw bytes from it into a provided buffer (such as that returned by secret.borrow_mut()).
That's not the most useful thing right now since generally you want to read lines (which go into a String). I can look and see what I can do about providing a way to borrow the internal contents directly as a string.