Get Passwords From Mac's Keychain Access App In Rust
TL;DR
Code
use security_framework::passwords::get_generic_password;
fn main() {
dbg!(password("example-password", "alan"));
}
fn password(pass: &str, name: &str) -> String {
let load_thing = get_generic_password(pass, name);
String::from_utf8(load_thing.unwrap()).unwrap()
}
I don't like using plain-text config or .env files for storing passwords. Beyond the possibility of accidentally sending them to github I also stream which opens up an entirely new way to dox credentials.
Here's what I'm using in Rust to pull credentials out of my mac's built-in Keychain Access app:
Note
It looks like the repo was archived in July 2023. It's still working for me.
Reference
Bindings to the Apple's Security.framework. Allows use of TLS and Keychain from Rust.