Keyring-rs
A cross-platorm library and utility to manage passwords.
Very basic autogenerated docs. (Only linux docs are available at this time, cross-platform autogenerated docs are not a thing yet)
Please read this readme for the explanation of how to use this library.
Usage
Currently supports Linux, macOS, and Windows. Please file issues if you have any problems or bugs!
To use this library in your project add the following to your Cargo.toml file:
keyring = "0.6.1"
This will give you access to the keyring crate in your code. Now you can use
the new function to get an instance of the Keyring struct. The new
function expects a service name and an username with which it accesses
the password.
You can get a password from the OS keyring with the get_password function.
extern crate keyring;
use Error;
Passwords can also be added to the keyring using the set_password function.
extern crate keyring;
use Error;
And they can be deleted with the delete_password function.
extern crate keyring;
use Error;
Errors
The get_password, set_password and delete_password functions return a
Result which, if the operation was unsuccessful, can yield a KeyringError.
The KeyringError struct implements the error::Error and fmt::Display
traits, so it can be queried for a cause and an description using methods of
the same name.
Caveats
macOS
- Special characters support is experimental. Please file an issue if this gives you trouble.
- Handles empty string input appropriately (encrypts and decrypts)
Linux
- The application name is hardcoded to be
rust-keyring. - Does not handle empty string input appropriately (decrypts but does not encrypt. This is a limitation of the current implementation of rust-crypto)
Dev Notes
- If you're running tests, please use
RUST_TEST_THREADS=1 cargo test
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributors
Thanks to the following for helping make this library better, whether through contributing code, discussion, or bug reports!
- @dario23
- @dten
- @jasikpark
- @jonathanmorley
- @lexxvir
- @Phrohdoh
- @Rukenshia
- @samuela
- @stankec
- @steveatinfincia
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.