From 61fa41c888db6565973ea1777cab130f5186803a Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sat, 8 May 2021 17:55:16 +0200 Subject: [PATCH] GUI: Added button to generate a random password to the "Encrypt" tab. --- frontend/src/main.c | 2 +- gui/Controls/ImageButton.xaml | 12 ++ gui/Controls/ImageButton.xaml.cs | 54 +++++++++ gui/Controls/ImageToggleButton.xaml.cs | 24 ++++ gui/Controls/PasswordToggleBox.xaml.cs | 11 ++ gui/Resources/Refresh.png | Bin 0 -> 674 bytes gui/SlunkCryptGUI.csproj | 11 ++ gui/SlunkCryptGUI.xaml | 28 ++--- gui/SlunkCryptGUI.xaml.cs | 40 ++++++- gui/Utilities/SecureRandom.cs | 146 +++++++++++++++++++++++++ 10 files changed, 312 insertions(+), 16 deletions(-) create mode 100644 gui/Controls/ImageButton.xaml create mode 100644 gui/Controls/ImageButton.xaml.cs create mode 100644 gui/Resources/Refresh.png create mode 100644 gui/Utilities/SecureRandom.cs diff --git a/frontend/src/main.c b/frontend/src/main.c index 8a349be..cea5e71 100644 --- a/frontend/src/main.c +++ b/frontend/src/main.c @@ -35,7 +35,7 @@ #define MODE_TEST 5 static const size_t RCMD_PWDLEN_LENGTH = 12U; -static const size_t DFLT_PWDLEN_LENGTH = 20U; +static const size_t DFLT_PWDLEN_LENGTH = 24U; static const CHR* const ENV_PASSWORD = T("SLUNK_PASSPHRASE"); static const CHR* const ENV_KEEPFILE = T("SLUNK_KEEP_INCOMPLETE"); diff --git a/gui/Controls/ImageButton.xaml b/gui/Controls/ImageButton.xaml new file mode 100644 index 0000000..b011df0 --- /dev/null +++ b/gui/Controls/ImageButton.xaml @@ -0,0 +1,12 @@ + + + + diff --git a/gui/Controls/ImageButton.xaml.cs b/gui/Controls/ImageButton.xaml.cs new file mode 100644 index 0000000..10fc16e --- /dev/null +++ b/gui/Controls/ImageButton.xaml.cs @@ -0,0 +1,54 @@ +/******************************************************************************/ +/* SlunkCrypt, by LoRd_MuldeR */ +/* This work has been released under the CC0 1.0 Universal license! */ +/******************************************************************************/ + +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; + +namespace com.muldersoft.slunkcrypt.gui.ctrls +{ + /// + /// Interaction logic for ImageToggleButton.xaml + /// + public partial class ImageButton : UserControl + { + public event RoutedEventHandler Clicked; + + public ImageButton() + { + InitializeComponent(); + Button.Click += ButtonClicked; + } + + public ImageSource ImageSource + { + get + { + return ButtonImage.Source; + } + set + { + ButtonImage.Source = value; + } + } + + public string ButtonToolTip + { + get + { + return ButtonImage.ToolTip as string; + } + set + { + ButtonImage.ToolTip = value; + } + } + + private void ButtonClicked(object sender, RoutedEventArgs e) + { + Clicked?.Invoke(this, e); + } + } +} diff --git a/gui/Controls/ImageToggleButton.xaml.cs b/gui/Controls/ImageToggleButton.xaml.cs index 9fa5536..3230ce0 100644 --- a/gui/Controls/ImageToggleButton.xaml.cs +++ b/gui/Controls/ImageToggleButton.xaml.cs @@ -62,6 +62,30 @@ namespace com.muldersoft.slunkcrypt.gui.ctrls } } + public string ToolTipDefault + { + get + { + return Image_Default.ToolTip as string; + } + set + { + Image_Default.ToolTip = value; + } + } + + public string ToolTipChecked + { + get + { + return Image_Checked.ToolTip as string; + } + set + { + Image_Checked.ToolTip = value; + } + } + private void OnCheckedChanged(object sender, RoutedEventArgs e) { NotifyPropertyChanged("IsChecked"); diff --git a/gui/Controls/PasswordToggleBox.xaml.cs b/gui/Controls/PasswordToggleBox.xaml.cs index 6cf018f..20c1896 100644 --- a/gui/Controls/PasswordToggleBox.xaml.cs +++ b/gui/Controls/PasswordToggleBox.xaml.cs @@ -87,6 +87,17 @@ namespace com.muldersoft.slunkcrypt.gui.ctrls { return IsRevealed ? Edit_Normal.Text : Edit_Hidden.Password; } + set + { + if (IsRevealed) + { + Edit_Normal.Text = string.IsNullOrEmpty(value) ? string.Empty : value; + } + else + { + Edit_Hidden.Password = string.IsNullOrEmpty(value) ? string.Empty : value; + } + } } public void Clear() diff --git a/gui/Resources/Refresh.png b/gui/Resources/Refresh.png new file mode 100644 index 0000000000000000000000000000000000000000..257cfee396d5cbebd839de85ce07de888f4ea206 GIT binary patch literal 674 zcmV;T0$u%yP)c5r#tc9wCFE4rIa-!1q-0q!CnXT4+IPh@KIlp_)|DJ;of^@6O&$Qb|%0Qj}Sozsbo8Q|>Mbn=U zP2E7#wB?O`Ep!GZny!_X7GPuz^XAJUAIBgXg^BNwVUi{61V^rojQRaE_qNj4NLdoVFk+|dMdJ*; zhruC&vq5gXzRrV0P}bF)f!c~)+<0;`kvy2BK~0+`3U)UG7hM{IuyBhaR6s z^E4C0gyZR%rDXZ6T~Z#euCIvb`VE|rHoo@?;#gG;J%Lwr*M*c6rP9`TeALEboY+=M z_9iFvJX#TP`AWOxTOW5H#;`tQNBIm9*+5DUdmdObp`;j!>}EcEvauMR>P~t_*#n}! zx{k1Mn;#1yWC@t0h{~O4*tM2I<{~!k28MaoAd1baJIiXe5uVjC=3!%jS3*P_5Qj*e zMuH)F`}<^aT#vEUo#>M7I&k@5J6}Uhj82Wy|5@Hbx@RKrQvzahya-(6+;Z6|hDkxh z+p$h@q{FG4u2oi&6#bWJbgAj{v=B}^Y5y2!b=uZ+`M(4h0H#Ie$NWKnJpcdz07*qo IM6N<$g2$IKwEzGB literal 0 HcmV?d00001 diff --git a/gui/SlunkCryptGUI.csproj b/gui/SlunkCryptGUI.csproj index aa9dc54..55426de 100644 --- a/gui/SlunkCryptGUI.csproj +++ b/gui/SlunkCryptGUI.csproj @@ -70,6 +70,9 @@ Hyperlink.xaml + + ImageButton.xaml + ImageToggleButton.xaml @@ -79,6 +82,7 @@ + @@ -88,6 +92,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -175,6 +183,9 @@ + + +