Skip to content

Commit

Permalink
Merge pull request #2 from 08820048/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
08820048 authored Jun 1, 2024
2 parents 02df871 + 49d8747 commit 5fa003d
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 25 deletions.
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

# xpwd Change Log

## 2024-05-30
## v1.0.0

- Initiate project conception and establish project plan
- Complete project setup, named "DigitShield"
- Implement core feature: Quick password generation

---

## 2024-05-31
## v1.0.1

- Adopt a new name and a tentative `Logo`

Expand All @@ -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`.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
36 changes: 29 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div align="center">
<img src="https://images.waer.ltd/notes/20240601113455.png" width="140px" />

[![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)
Expand Down Expand Up @@ -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
```

Expand Down Expand Up @@ -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.**

37 changes: 30 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use colored::*;
use prettytable::{cell, row, Table};
use rand::distributions::Alphanumeric;
use rand::prelude::*;
use rand::seq::SliceRandom;
Expand Down Expand Up @@ -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, &[]);
Expand All @@ -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
}
}
21 changes: 16 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -41,15 +42,15 @@ fn print_infos() {
println!(
"{}",
Blue.paint(
r#"
_______ ______
|\ /| ( ____ )|\ /|( __ \
r#"
_______ ______
|\ /| ( ____ )|\ /|( __ \
( \ / ) | ( )|| ) ( || ( \ )
\ (_) /_____ | (____)|| | _ | || | ) |
) _ ((_____)| _____)| |( )| || | | |
/ ( ) \ | ( | || || || | ) |
( / \ ) | ) | () () || (__/ )
|/ \| |/ (_______)(______/
|/ \| |/ (_______)(______/
"#
)
);
Expand All @@ -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");

Expand Down

0 comments on commit 5fa003d

Please sign in to comment.