Crate rustgenpass
source · [−]Expand description
An implementation in Rust of the SuperGenPass utility.
Hash a master password into unique, complex passwords specific for each website.
Examples
Use default to parse domain from URL and strip subdomains
use rustgenpass::generate_with_url;
let generated_password = generate_with_url("masterpassword", "http://www.example.com/foo/bar.html");
assert_eq!("jHMOHn7bRs", generated_password);
With configuration matching defaults
use rustgenpass::{generate_with_config, HashAlgorithm, GenerateConfig};
let generated_password = generate_with_config("masterpassword", "example.com", GenerateConfig::default());
assert_eq!("jHMOHn7bRs", generated_password);
With configuration matching defaults
use rustgenpass::{generate_with_config, HashAlgorithm, GenerateConfig};
let config = GenerateConfig {
secret: Some("secret".to_string()),
length: 24,
hash_rounds: 50,
..GenerateConfig::default()
};
let generated_password = generate_with_config("masterpassword", "example.com", config);
assert_eq!("izHhm22SMfZeg8Q3t2BrZgAA", generated_password);
Full example with hostname isolation from URL
use rustgenpass::{get_hostname, generate_with_config, HashAlgorithm, GenerateConfig};
let config = GenerateConfig {
secret: Some("secret".to_string()),
length: 24,
hash_rounds: 50,
..GenerateConfig::default()
};
let domain = get_hostname("https://www.example.com/foo/bar.html").unwrap();
let generated_password = generate_with_config("masterpassword", &domain, config);
assert_eq!("izHhm22SMfZeg8Q3t2BrZgAA", generated_password);
Full example using SHA512 hashing
use rustgenpass::{get_hostname, generate_with_config, HashAlgorithm, GenerateConfig};
let config = GenerateConfig {
secret: Some("secret".to_string()),
length: 24,
hash_rounds: 50,
hash_algorithm: HashAlgorithm::SHA512,
};
let domain = get_hostname("https://www.example.com/foo/bar.html").unwrap();
let generated_password = generate_with_config("masterpassword", &domain, config);
assert_eq!("awqhRUhYQSj48FIp678e84LO", generated_password);
Full example with passthrough of URL
use rustgenpass::{get_hostname_with_config, generate_with_config, HostnameConfig, GenerateConfig, HashAlgorithm};
let config = HostnameConfig { passthrough: true, ..HostnameConfig::default() };
let generate_config = GenerateConfig {
length: 24,
hash_rounds: 50,
..GenerateConfig::default()
};
let domain = get_hostname_with_config("https://www.example.com/foo/bar.html", config).unwrap();
let generated_password = generate_with_config("masterpassword", &domain, generate_config);
assert_eq!("ufLehPcQ8FgvRZX8ZHOg5wAA", generated_password);
Structs
Enums
Supported hashing algorithms
Functions
Generate a hashed password with default options.
Generate a hashed password with given options.
Generate a hashed password from URL with default options.
Isolate the domain name of a URL with default config.
Isolate the domain name of a URL.