diff options
author | Guillaume <guillaumelacasa@hotmail.com> | 2013-06-13 20:19:15 +0200 |
---|---|---|
committer | Guillaume <guillaumelacasa@hotmail.com> | 2013-06-13 20:19:15 +0200 |
commit | b8279017597a616b016f8f1def3be11ac9660f5d (patch) | |
tree | 26aa7d7f904c5b10baa62361150fbab82de74b0b | |
parent | fb24badd216bc50e5a00ab87d7e7f4abc1208142 (diff) | |
download | TwoStepsAuthenticator-b8279017597a616b016f8f1def3be11ac9660f5d.zip TwoStepsAuthenticator-b8279017597a616b016f8f1def3be11ac9660f5d.tar.gz TwoStepsAuthenticator-b8279017597a616b016f8f1def3be11ac9660f5d.tar.bz2 |
Key generator added
-rw-r--r-- | TwoStepsAuthenticator.TestApp/MainWindow.xaml.cs | 1 | ||||
-rw-r--r-- | TwoStepsAuthenticator.TestApp/ViewModel.cs | 2 | ||||
-rw-r--r-- | TwoStepsAuthenticator/Authenticator.cs | 9 |
3 files changed, 10 insertions, 2 deletions
diff --git a/TwoStepsAuthenticator.TestApp/MainWindow.xaml.cs b/TwoStepsAuthenticator.TestApp/MainWindow.xaml.cs index 43469af..f74a031 100644 --- a/TwoStepsAuthenticator.TestApp/MainWindow.xaml.cs +++ b/TwoStepsAuthenticator.TestApp/MainWindow.xaml.cs @@ -25,7 +25,6 @@ namespace TwoStepsAuthenticatorTestApp { InitializeComponent(); model = new ViewModel(); - model.Key="JBSWY3DPEHPK3PXP"; this.DataContext = model; } diff --git a/TwoStepsAuthenticator.TestApp/ViewModel.cs b/TwoStepsAuthenticator.TestApp/ViewModel.cs index 51db3a8..191569f 100644 --- a/TwoStepsAuthenticator.TestApp/ViewModel.cs +++ b/TwoStepsAuthenticator.TestApp/ViewModel.cs @@ -72,6 +72,8 @@ namespace TwoStepsAuthenticatorTestApp public ViewModel() { + var auth = new TwoStepsAuthenticator.Authenticator(); + this.Key = auth.GenerateKey(); timer = new DispatcherTimer(TimeSpan.FromSeconds(1), DispatcherPriority.Normal, timerCallback, App.Current.Dispatcher); //timer.Elapsed += timer_Elapsed; timer.Start(); diff --git a/TwoStepsAuthenticator/Authenticator.cs b/TwoStepsAuthenticator/Authenticator.cs index d196525..a026e57 100644 --- a/TwoStepsAuthenticator/Authenticator.cs +++ b/TwoStepsAuthenticator/Authenticator.cs @@ -13,7 +13,14 @@ namespace TwoStepsAuthenticator public string GenerateKey() { - throw new NotImplementedException(); + var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + var random = new Random(); + var keyChars = new char[16]; + for (int i = 0; i < 16; i++) + { + keyChars[i] = chars[random.Next(chars.Length)]; + } + return new String(keyChars); } public string GetCode(string secret) |