From 4ad50b1f6e88ae8235cf57d39c98cfa5ea25b40a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AB=E5=B0=BA?= Date: Sat, 1 Jun 2024 13:45:06 +0800 Subject: [PATCH 1/2] Bump version to 1.0.1, update README badges, enhance password display and strength evaluation. Add data table printing function for password details. Bump version to 1.0.1, update README badges, enhance password display and strength evaluation. Add data table printing function for password details. - Updated version to 1.0.1 - Enhanced password display and strength evaluation - Added data table printing function for password details --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 36 +++++++++++++++++++++++++++++------- src/lib.rs | 37 ++++++++++++++++++++++++++++++------- src/main.rs | 21 ++++++++++++++++----- 5 files changed, 77 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index be4a698..196b649 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1741,7 +1741,7 @@ dependencies = [ [[package]] name = "xpwd" -version = "1.0.0" +version = "1.0.1" dependencies = [ "ansi_term", "clap", diff --git a/Cargo.toml b/Cargo.toml index 82f7b66..b92c33e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xpwd" -version = "1.0.0" +version = "1.0.1" edition = "2021" authors = ["Code0408"] description = "A simple and quick password generator for enhanced security." diff --git a/README.md b/README.md index 444bb94..96019af 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@
-[![Crates.io](https://img.shields.io/crates/d/quick_pswd.svg)](https://crates.io/crates/xpwd) +[![Crates.io](https://img.shields.io/crates/d/xpwd.svg)](https://crates.io/crates/xpwd) [![License](https://img.shields.io/github/license/08820048/xpwd)](https://github.com/08820048/xpwd/blob/master/LICENSE) [![rustc 1.77.0](https://img.shields.io/badge/rust-1.77.0-orange.svg)](https://img.shields.io/badge/rust-1.77.0-orange.svg) [![Documentation](https://docs.rs/console/badge.svg)](https://docs.rs/xpwd) @@ -57,13 +57,36 @@ Options: $ xpwd -l 8 -c s - j1618a59 ++-----+---------+----------+ +| Len | complex | password | ++-----+---------+----------+ +| 8 | simple | ld0an6qr | ++-----+---------+----------+ +🛡️ ■■■■■■■■■■■■■■■■■■■■ moderate $ xpwd -l 16 -c m -Cio6PYtg30mLYtHC - -$ xpwd -l 18 -c c -yd;mW)[1sW5q3p)6.Y ++-----+---------+------------------+ +| Len | complex | password | ++-----+---------+------------------+ +| 16 | medium | DwkYFtnVRhYoVAgk | ++-----+---------+------------------+ +🛡️ ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ very strong + +$ xpwd -l 5 -c c ++-----+---------+----------+ +| Len | complex | password | ++-----+---------+----------+ +| 5 | complex | RtVUj | ++-----+---------+----------+ +🛡️ ■■■■■■■■■■■■■ weak + +$ cargo run -- -l 3 -c s ++-----+---------+----------+ +| Len | complex | password | ++-----+---------+----------+ +| 3 | simple | pl9 | ++-----+---------+----------+ +🛡️ ■■■■■■■■ very weak ``` @@ -115,4 +138,3 @@ This project is licensed under the MIT License - see the [LICENSE](https://githu ## about **In order to provide a more efficient and convenient user experience, the original project quick_pswd (https://crates.io/crates/quick_pswd) has officially been renamed to xpwd.** - diff --git a/src/lib.rs b/src/lib.rs index 94357d3..f0f46e6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ use colored::*; +use prettytable::{cell, row, Table}; use rand::distributions::Alphanumeric; use rand::prelude::*; use rand::seq::SliceRandom; @@ -89,6 +90,16 @@ pub fn gen_password(len: usize, complexity: &str) -> String { .collect() } +pub fn print_data_tables(datas: &[(String, String, String)]) { + let mut table = Table::new(); + table.add_row(row![cell!("Len"), cell!("complex"), cell!("password")]); + + for (p1, p2, p3) in datas { + table.add_row(row![p1, p2, p3]); + } + table.printstd(); +} + // Evaluates the strength of a given password fn evaluate_password_strength(password: &str) -> u8 { let result = zxcvbn(password, &[]); @@ -98,13 +109,25 @@ fn evaluate_password_strength(password: &str) -> u8 { // Prints a visual representation of the password strength pub fn print_password_strength(password: &str) { let score = evaluate_password_strength(password); - print!("Strength:"); + print!("🛡️ "); match score { - 0 => println!("{}", "■■■■■■■■".red()), // Weak - 1 => println!("{}", "■■■■■■■■■■■■■".magenta()), // Very Weak - 2 => println!("{}", "■■■■■■■■■■■■■■■■■■■■".yellow()), // Weak - 3 => println!("{}", "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■".cyan()), // Medium - 4 => println!("{}", "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■".green()), // Strong - _ => unreachable!(), // Handle any unexpected cases + 0 => println!("{} {}", "■■■■■■■■".red(), "very weak".red()), // Weak + 1 => println!("{} {}", "■■■■■■■■■■■■■".magenta(), "weak".magenta()), // Very Weak + 2 => println!( + "{} {}", + "■■■■■■■■■■■■■■■■■■■■".yellow(), + "moderate".yellow() + ), // Weak + 3 => println!( + "{} {}", + "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■".cyan(), + "strong".cyan() + ), // Medium + 4 => println!( + "{} {}", + "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■".green(), + "very strong".green() + ), // Strong + _ => unreachable!(), // Handle any unexpected cases } } diff --git a/src/main.rs b/src/main.rs index 3ef99cc..fd01c26 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ use clipboard::ClipboardContext; use clipboard::ClipboardProvider; use colored::Colorize; use notify_rust::Notification; +use prettytable::{cell, row, Table}; use xpwd::*; /// Command line arguments structure. @@ -41,15 +42,15 @@ fn print_infos() { println!( "{}", Blue.paint( - r#" - _______ ______ -|\ /| ( ____ )|\ /|( __ \ + r#" + _______ ______ +|\ /| ( ____ )|\ /|( __ \ ( \ / ) | ( )|| ) ( || ( \ ) \ (_) /_____ | (____)|| | _ | || | ) | ) _ ((_____)| _____)| |( )| || | | | / ( ) \ | ( | || || || | ) | ( / \ ) | ) | () () || (__/ ) -|/ \| |/ (_______)(______/ +|/ \| |/ (_______)(______/ "# ) ); @@ -63,8 +64,18 @@ fn main() { Some(ref password) => print_password_strength(password), None => { let pwd = gen_password(args.len, &args.complex); + let mut c = args.complex; + match c.as_str() { + "s" => c = "simple".to_string(), + "m" => c = "medium".to_string(), + "c" => c = "complex".to_string(), + _ => {} + } + let datas = vec![(args.len.to_string(), c, pwd.clone())]; - println!("Your Password:\t{}", pwd.magenta()); + print_data_tables(&datas); + print_password_strength(pwd.as_str()); + //println!("{}\n\n", pwd.magenta()); println!("\n\n"); From 49d8747988234befd1bd7a8cf432981e3ed5ab6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AB=E5=B0=BA?= Date: Sat, 1 Jun 2024 13:52:34 +0800 Subject: [PATCH 2/2] Update CHANGELOG for v1.0.1-beta with enhanced features - Added desktop popup notification after password generation - Improved terminal output aesthetics and user experience --- CHANGELOG.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0c792d..dfa6b6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ # xpwd Change Log -## 2024-05-30 +## v1.0.0 - Initiate project conception and establish project plan - Complete project setup, named "DigitShield" @@ -10,7 +10,7 @@ --- -## 2024-05-31 +## v1.0.1 - Adopt a new name and a tentative `Logo` @@ -19,8 +19,9 @@ - Uploaded to `crates.io`, introducing `cargo install` as a new installation method ---- -## 2024-06-01 +## v1.0.1-beta - New feature: Desktop popup notification after password generation! - Adjusted the main function's code structure. - Fixed the project's character logo. -- Released version `v1.0.2`. +- Improving terminal output aesthetics and enhancing user experience. +- Released version `v1.0.1`.