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`.
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");