Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I handle Strings combined with Secret(Box)? #90

Open
mainrs opened this issue Apr 3, 2021 · 1 comment
Open

How do I handle Strings combined with Secret(Box)? #90

mainrs opened this issue Apr 3, 2021 · 1 comment

Comments

@mainrs
Copy link

mainrs commented Apr 3, 2021

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!

@stouset
Copy link
Owner

stouset commented Apr 5, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants