diff --git a/src/main.rs b/src/main.rs index 604dd4a..dc7b8f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -225,17 +225,30 @@ impl eframe::App for App { ui.add_space(10.0); ui.horizontal(|ui| { TextEdit::singleline(&mut self.password_buffer).password(true).ui(ui); - if let Some(entropy) = entropy(&self.password_buffer) { - let text = if entropy < 60_f64 { - WidgetText::from(format!("entropy: {:.2}", entropy)) - .color(Color32::from_rgb(220, 88, 42)) - } else { - WidgetText::from(format!("entropy: {:.2}", entropy)) - .color(Color32::from_rgb(144, 238, 144)) - }; + let text = if self.password_buffer.len() < 12 { + WidgetText::from(format!("length: {}", self.password_buffer.len())) + .color(Color32::from_rgb(240, 5, 5)) + } else { + WidgetText::from(format!("length: {}", self.password_buffer.len())) + .color(Color32::from_rgb(144, 238, 144)) + }; + ui.label(text); - ui.label(text); - } + let entropy = entropy(&self.password_buffer) + .or(Some(0.0)) + .unwrap(); + let text = if entropy < 35_f64 { + WidgetText::from(format!("entropy: {:.2}", entropy)) + .color(Color32::from_rgb(240, 5, 5)) + } else if entropy < 60_f64 { + WidgetText::from(format!("entropy: {:.2}", entropy)) + .color(Color32::from_rgb(220, 88, 42)) + } else { + WidgetText::from(format!("entropy: {:.2}", entropy)) + .color(Color32::from_rgb(144, 238, 144)) + }; + + ui.label(text); }); ui.add_space(7.5);