Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / passwords / src / main / rust / examples / gen_vault.rs
gen_vault.rs17 lines · 1.1 KiBRaw
| 1 | // Dev-only helper: write a KDBX vault with the Rust exporter so it can be |
| 2 | // re-opened by the old keepassjava2 library (reverse-direction interop check). |
| 3 | // Not shipped; excluded from the cdylib. Run: cargo run --example gen_vault -- <pw> <out> |
| 4 | use std::io::Write; |
| 5 | |
| 6 | fn main() { |
| 7 | let args: Vec<String> = std::env::args().collect(); |
| 8 | let pw = &args[1]; |
| 9 | let out = &args[2]; |
| 10 | let entries = r#"[ |
| 11 | {"Title":"GitHub","UserName":"octocat","Password":"s3cr3t!","URL":"https://github.com","Websites":"https://github.com\nhttps://gist.github.com","otp":"otpauth://totp/?secret=JBSWY3DPEHPK3PXP","_Type":"password"}, |
| 12 | {"Title":"Acme Passkey","UserName":"alice","URL":"acme.example","_Type":"passkey","KPEX_PASSKEY_USERNAME":"alice","KPEX_PASSKEY_PRIVATE_KEY_PEM":"TUlHSEFnRUE=","KPEX_PASSKEY_CREDENTIAL_ID":"cred-123","KPEX_PASSKEY_USER_HANDLE":"user-abc","KPEX_PASSKEY_RELYING_PARTY":"acme.example"} |
| 13 | ]"#; |
| 14 | let bytes = passwords_kdbx::export_kdbx(pw, entries).expect("export"); |
| 15 | std::fs::File::create(out).unwrap().write_all(&bytes).unwrap(); |
| 16 | println!("wrote {} ({} bytes)", out, bytes.len()); |
| 17 | } |