#general #store #save #file #destroy

dono

Rust crate for Dono Key Derivation Function

8 stable releases

Uses old Rust 2015

2.0.0 Oct 5, 2016
1.1.5 Aug 29, 2016
1.1.3 Aug 28, 2016
1.1.1 Aug 27, 2016
1.0.0 Aug 21, 2016
Download history 13/week @ 2023-10-25 7/week @ 2023-11-01 11/week @ 2023-11-08 2/week @ 2023-11-15 9/week @ 2023-11-22 35/week @ 2023-11-29 1/week @ 2023-12-06 9/week @ 2023-12-13 9/week @ 2023-12-20 17/week @ 2023-12-27 1/week @ 2024-01-03 2/week @ 2024-01-10 18/week @ 2024-01-17 17/week @ 2024-01-24 17/week @ 2024-01-31

54 downloads per month

GPL-3.0 license

20KB
387 lines

Dono Rust crate

Build Status codecov crates.io version license

🚚 Rust crate for Dono Key Derivation Function

About Dono

Dono is a password derivation tool which derives passwords from a master Key by using short descriptions of the destination service.

You can read more about the project in it's whitepaper repository or download the PDF.

Usage

To use this crate add the following to your Cargo.toml file:

[dependencies]
dono = "2.0.0"

Then in your rust code:

extern crate dono;

This will give you access to the Dono and DonoError structs.

Dono

The Dono struct provides the basic password hashing implementation.

A new instance of Dono can be created with the new() function. This gives you access to the compute_password function.

extern crate dono;

fn main() {
  let dono = dono::Dono::new();

  let key = "this_is_a_long_test_key".to_string();
  let label = "test".to_string();

  let password = dono.compute_password(&key, &label).unwrap();

  println!("password: {}", password);
}

Label

The Label struct provides an easy-to-use way to index, create, update and destroy labels from the store.

Labels have the following attributes:

  • title - Holds the current title, represented as a String
  • previous_title - Holds the last saved title, represented as a String
  • persisted - Holds a bool value thet indicates if the Label is persisted in the store

Abailable public methods are:

  • new(label: &String) -> Label - creates a new Label with the given title
  • new_saved(label: &String) -> Label - same as new but sets persisted to true
  • changed() -> bool - returns true if the current and previous title are the same
  • save() -> Result<&Label, DonoError> - save the label to the store
  • destroy() -> Result<&Label, DonoError> - destroys the label from the store

Module methods:

  • labels::all() - returns a Vec with all prebuild Label structs from the store

Example:

extern crate dono;

fn main() {
  /* Initial state of the store:
   * github
   * facebook
   * twitter
   */

  // Return a Vec<Label> containing the github, facebook and twitter Labels
  let mut labels = dono::labels::all();

  // Get the twitter Label
  let mut twitter_label = labels.last_mut().unwrap();

  // Change the title from twitter to gitter
  twitter_label.title = "gitter".to_string();

  // Check if the value has changed
  println!("Value has changed? {}", twitter_label.changed());

  // Persist the changes
  twitter_label.save().unwrap();

  /* Current state of the store:
   * github
   * facebook
   * gitter
   */

  // Delete the gitter label
  twitter_label.destroy();

  /* Current state of the store:
   * github
   * facebook
   */

  // Create a new label
  let mut label  = dono::labels::Label::new(&"test".to_string());

  // Save the new label
  label.save();

  /* Current state of the store:
   * github
   * facebook
   * test
   */
}

Errors

This library has a custom error called DonoError that has the following string fields in it:

  • field - Indicates which parameter caused the error
  • code - A code associated with that error
  • description - Detailed description of what went wrong with possible solution
  • message - Short description of what went wrong

Error codes:

  • CP001 - The key is too short
  • CP002 - Desired password length is too long
  • SV001 - Could not open store file
  • SV002 - Could not write to store file

OSS used

Contributing

Contributions are always welcome! Please note that new features and bugfixes get added on the develop branch first. So all pull requests should be made from and to the develop branch. Also, please check the issues and pull request pages for simmilar issues and solutions before submitting your own.

When you submit a bug report always add a minimal working example and specify which version of the crate you are using.

Testing is important! Always test the code you submit in a pull request.

License

This project is licensed under the GPLv3. The full license text is available here.

Dependencies

~7.5MB
~124K SLoC