securepass

Crates.iosecurepass
lib.rssecurepass
version0.3.3
sourcesrc
created_at2024-06-24 18:15:45.393658
updated_at2024-09-22 18:07:34.365444
descriptionA password generator and balancer library in Rust
homepagehttps://github.com/Sworzen1/securepass
repositoryhttps://github.com/Sworzen1/securepass
max_upload_size
id1282422
size92,846
Bartlomiej Sworzen (Sworzen1)

documentation

https://docs.rs/securepass/latest/securepass/

README

Password Generator Library in Rust

This Rust library provides functions to generate random passwords, balance password, generate password with customizable options and password strength level based on calculation password entropy and check password has common words.

Features

  • Generate random passwords with specified length and charset.
  • Option to include uppercase letters, numbers, and special characters.
  • Password strength checking based on entropy level and common password dictionary.
  • Balance weak password.
  • Calculate password entropy.

Usage

Add this library to your Cargo.toml:

[dependencies]
password_generator = "0.3.3"

To get default options:

let default_options = securepass::PasswordOptions::default();

Options struct and default:

PasswordOptions {
    pub length:usize, // 13
    pub include_special_chars:bool, // true
    pub include_uppercase:bool, // true
    pub include_numbers:bool, // true
    pub with_balancing:bool, // true
    pub phrase:Option<String> // None
}

To generate random password:

let new_random_password = securepass::generate_random_password(%EXAMPLE_CHARSET%, %LENGTH%); // returns String

To generate password with default options:

let default_options = securepass::PasswordOptions::default();
let password_with_options = default_options.generate_password(); // returns Result<String, String>

To generate password from phrase:

let options = securepass::PasswordOptions {
    phrase: Some("rust is awesome".to_string()),
    ..Default::default()
};
let password_from_phrase = options.generate_password(); // returns Result<String, String>

To check password strength:

let password_strength = securepass::check_password_strength(%PASSWORD%); // returns Result<PasswordStrength, String>

To balance password:

let mut password = %WEAK_PASSWORD%.to_string();
let balanced_password = securepass::balance_password(&mut password); // returns String

To calculate password entropy:

let entropy = securepass::calculate_entropy(%PASSWORD%); // returns float

Documentation

You can find full Rust documentation about securepass here.

Commit count: 20

cargo fmt