Secwords

CI Crates.io Licensed Twitter

secure and safe password container.

| Docs | Latest Note |

toml [dependencies] secwords = "2.1.0"

or

toml [dependencies] secwords = { version = "2.1.0", default-features = false } # no-std


How to

``rust use secwords::Password; use sha2::Sha256; // can be any hasher of dyn Digestdigest` crate

let plain = String::from("pa5$wOrs"); // <- example

let pass1 = Password::::new(plain).unwrap(); // min length = 6 let pass2: Password = "pa5$wOrs".parse().unwrap();

asserteq!(pass1, pass2); // they are hashed, original is gone(safely) asserteq!(pass1.len(), 32); // fixed size vep(crate) asserteq!(pass1.asref(), pass2.asslice()); asserteq!(pass1.tovec(), pass2.tovec());

asserteq!(pass1, "pa5$wOrs"); asserteq!(pass1, String::from("pa5$wOrs")); asserteq!(&pass1.tohex().unwrap()[..20], "0f521249b366dd6e0acc"); asserteq!(format!("{}", pass1), "*SECURE*"); // display asserteq!(format!("{:?}", pass1), "SECURE"); // debug

let bytes = pass1.tobytes(); // encode let pass3 = Password::::frombytes(bytes).unwrap(); // decode assert_eq!(pass1, pass3);

let hexstring = pass1.tohex().unwrap(); // encode let pass3 = Password::::fromhex(hexstring).unwrap(); // decode assert_eq!(pass1, pass3); `` there are more examples in thelib.rs`