8 releases

0.4.0 May 4, 2020
0.3.2 Jan 25, 2020
0.3.1 Jun 12, 2019
0.2.1 Apr 16, 2019
0.1.1 Mar 25, 2019

#960 in Authentication

Download history 24/week @ 2023-10-28 16/week @ 2023-11-04 10/week @ 2023-11-11 12/week @ 2023-11-18 35/week @ 2023-11-25 20/week @ 2023-12-02 16/week @ 2023-12-09 9/week @ 2023-12-16 24/week @ 2023-12-23 4/week @ 2023-12-30 16/week @ 2024-01-06 8/week @ 2024-01-13 14/week @ 2024-01-20 20/week @ 2024-01-27 7/week @ 2024-02-03 34/week @ 2024-02-10

76 downloads per month
Used in knox

MIT and LGPL-2.1

77KB
1.5K SLoC

libknox

libknox is the library behing the knox secret manager.

You can refer to the repository or the documentation for usage information.

Example

use libknox::*;

fn main() {
  // Create a new vault with the given GPG identity
  let id = vec!["vault-test@apognu.github.com".to_string()];
  let mut vault = VaultContext::create("/tmp/knox-example", &id).expect("FAIL");

  // Create a new entry with three attributes
  let mut entry = Entry::new();
  entry.add_attribute("username", "bob");
  entry.add_confidential_attribute("password", "foobar");
  entry.add_confidential_attribute(
    "apikey",
    "3OJL07P+W5zODH2J1Wv7rXh5i9UpR0mpvPW7ygIMih82J8P95krJZXyERqbi/XS",
  );

  // Write the entry and the metadata pointing to it
  vault
    .write_entry("personal/website.com", &entry)
    .expect("FAIL");

  // Open the previously created vault and read the written entry
  let vault = VaultContext::open("/tmp/knox-example").expect("FAIL");
  let entry = vault.read_entry("personal/website.com").expect("FAIL");

  // Loop over the attributes and print them
  for (key, attribute) in entry.get_attributes() {
    if attribute.confidential {
      println!("{} = {} (CONFIDENTIAL)", key, attribute.value);
    } else {
      println!("{} = {}", key, attribute.value);
    }
  }
}

Dependencies

~16MB
~352K SLoC