private void Regenerate() { if (CanCreatePhrase) { int num = NumWords; Words = new string[num]; var randomness = RandomnessSourceList.SelectedItem as IRandomnessSource; Wordsource = WordsSourceList.SelectedItem as IWordSource; int wordsourceNumWords = Wordsource.NumWords(); double perWord = Math.Log(wordsourceNumWords, 2); double bits = Words.Length * perWord; Utils.GetWords(num, Words, Wordsource, randomness); PassphraseOutput = String.Join(" ", Words); DoCrackingCalculations(); NumBitsOutput = String.Format("{0:0.##} bits", bits); NumBitsTooltip = Utils.BitText(perWord, num, bits, wordsourceNumWords); perWord = Math.Log(_alphanumSource.NumWords(), 2); int alphWords = 0; //(int) Math.Ceiling((float)bits / perWord); while (alphWords * perWord < bits) { alphWords++; } var alphanumWords = new string[alphWords]; bits = alphWords * perWord; Utils.GetWords(alphWords, alphanumWords, _alphanumSource, randomness); AlphanumOutput = String.Join("", alphanumWords); AlphanumBitsText = Utils.BitText(perWord, alphWords, bits, _alphanumSource.NumWords()); NotifyPropertyChanged("PassphraseOutput"); NotifyPropertyChanged("PassphraseBitsText"); NotifyPropertyChanged("AlphanumOutput"); NotifyPropertyChanged("AlphanumBitsText"); NotifyPropertyChanged("NumBitsOutput"); NotifyPropertyChanged("NumBitsTooltip"); } }