# 🔐 secret-lib
Rust library to retrieve secrets from different sources: from raw string, from shell commands using [process-lib](https://docs.rs/process-lib/latest/process/) or from global keyring using [keyring-lib](https://docs.rs/keyring-lib/latest/keyring/).
See the full [API documentation](https://docs.rs/secret-lib/latest/secret/) and [some examples](https://git.sr.ht/~soywod/pimalaya/tree/master/item/secret/tests).
```rust
use secret::{keyring, Secret};
#[tokio::main]
async fn main() {
// raw secret
let mut secret = Secret::new_raw("secret");
assert_eq!(secret.get().await.unwrap(), "secret");
// shell command secret
let mut secret = Secret::new_cmd("echo 'secret'");
assert_eq!(secret.get().await.unwrap(), "secret");
// keyring secret
let entry = keyring::KeyringEntry::try_new("key")
.unwrap()
.try_with_secret("secret")
.await
.unwrap();
let mut secret = Secret::new_keyring_entry(entry);
assert_eq!(secret.get().await.unwrap(), "secret");
}
```
## Development
The development environment is managed by [Nix](https://nixos.org/download.html). Running `nix-shell` will spawn a shell with everything you need to get started with the lib: `cargo`, `cargo-watch`, `rust-bin`, `rust-analyzer`…
```sh
# Start a Nix shell
$ nix-shell
# then build the lib
$ cargo build -p secret-lib
```
## Contributing
A **bug tracker** is available on [SourceHut](https://todo.sr.ht/~soywod/pimalaya). <sup>[[send an email](mailto:~soywod/pimalaya@todo.sr.ht)]</sup>
A **mailing list** is available on [SourceHut](https://lists.sr.ht/~soywod/pimalaya). <sup>[[send an email](mailto:~soywod/pimalaya@lists.sr.ht)] [[subscribe](mailto:~soywod/pimalaya+subscribe@lists.sr.ht)] [[unsubscribe](mailto:~soywod/pimalaya+unsubscribe@lists.sr.ht)]</sup>
If you want to **report a bug**, please send an email at [~soywod/pimalaya@todo.sr.ht](mailto:~soywod/pimalaya@todo.sr.ht).
If you want to **propose a feature** or **fix a bug**, please send a patch at [~soywod/pimalaya@lists.sr.ht](mailto:~soywod/pimalaya@lists.sr.ht). The simplest way to send a patch is to use [git send-email](https://git-scm.com/docs/git-send-email), follow [this guide](https://git-send-email.io/) to configure git properly.
If you just want to **discuss** about the project, feel free to join the [Matrix](https://matrix.org/) workspace [#pimalaya](https://matrix.to/#/#pimalaya:matrix.org) or contact me directly [@soywod](https://matrix.to/#/@soywod:matrix.org). You can also use the mailing list.
## Sponsoring
[](https://nlnet.nl/project/Himalaya/index.html)
Special thanks to the [NLnet foundation](https://nlnet.nl/project/Himalaya/index.html) and the [European Commission](https://www.ngi.eu/) that helped the project to receive financial support from:
- [NGI Assure](https://nlnet.nl/assure/) in 2022
- [NGI Zero Entrust](https://nlnet.nl/entrust/) in 2023
If you appreciate the project, feel free to donate using one of the following providers:
[](https://github.com/sponsors/soywod)
[](https://www.paypal.com/paypalme/soywod)
[](https://ko-fi.com/soywod)
[](https://www.buymeacoffee.com/soywod)
[](https://liberapay.com/soywod)