Ignore:
Timestamp:
Sep 17, 2009, 12:28:06 PM (12 years ago)
Author:
angelov
Message:

Plugboard fixed. DictionaryHits input added.

Location:
trunk/CrypPlugins/MonoalphabeticAnalysis
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/MonoalphabeticAnalysis/MonoalphabeticAnalysis.cs

    r512 r525  
    188188            {
    189189                stringOutput = settings.WorkKey;
     190
     191                ((MonoalphabeticAnalysisSettings)this.settings).PlugBoard = stringOutput;
     192                ((MonoalphabeticAnalysisSettings)this.settings).WorkKey = stringOutput;
     193                ((MonoalphabeticAnalysisSettings)this.settings).ProposalKey = stringOutput;
     194                ((MonoalphabeticAnalysisSettings)this.settings).PlugboardRestart();
     195
     196
    190197                OnPropertyChanged("StringOutput");
    191198               
     
    285292
    286293
    287 
     294               
    288295                ((MonoalphabeticAnalysisSettings)this.settings).PlugBoard = stringOutput;
    289296                ((MonoalphabeticAnalysisSettings)this.settings).WorkKey = stringOutput;
    290297                ((MonoalphabeticAnalysisSettings)this.settings).ProposalKey = stringOutput;
    291                
     298                ((MonoalphabeticAnalysisSettings)this.settings).PlugboardRestart();
    292299                OnPropertyChanged("StringOutput");
    293300            }
  • trunk/CrypPlugins/MonoalphabeticAnalysis/MonoalphabeticAnalysisSettings.cs

    r512 r525  
    4141            }
    4242        }
     43        private StringBuilder plugBoard = new StringBuilder("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
     44        public void PlugboardRestart()
     45        {
     46           
     47            this.plugBoard = new StringBuilder("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
     48            for (int i = 0; i < alphabet.Length; i++)
     49            {
     50
     51               
     52               OnPropertyChanged("PlugBoard" + alphabet[i]);
     53            }
     54            OnPropertyChanged("PlugBoard");
     55           
     56        }
     57
     58
    4359
    4460        private string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    4561        //private bool involutoricPlugBoard = true;
    4662        private bool suggestSubstitutionManually = false;
    47         private string plugBoard = "";
     63       
    4864       
    4965        private char[] workKeyCharArray = new char[26];
     
    5268        private void setPlugBoard(int letterPos, int newIndex)
    5369        {
     70            if (workKey.Length != 0 && proposalKey.Length!=0)
     71            {
    5472                if (workKey[letterPos] != proposalKey[letterPos]) //Change has been made. Must be undone
    55                 {   hasChanges=true;
    56                     this.workKeyCharArray = this.workKey.ToCharArray(); 
     73                {
     74                    hasChanges = true;
     75                    this.workKeyCharArray = this.workKey.ToCharArray();
    5776                    char currentworkchar = this.workKey[letterPos];
    5877                    this.workKeyCharArray[letterPos] = this.proposalKey[letterPos];
    5978                    int indexofcurrentworkchar = this.proposalKey.IndexOf(currentworkchar);
    6079                    this.workKeyCharArray[indexofcurrentworkchar] = currentworkchar;
    61                     this.workKey= new string(this.workKeyCharArray);
    62                 }
     80                    this.workKey = new string(this.workKeyCharArray);
     81                    //same change also to plugboard
     82                    char currentPlugChar = plugBoard[letterPos];
     83                    char oldPlugChar = plugBoard[indexofcurrentworkchar];
     84                    plugBoard[indexofcurrentworkchar] = oldPlugChar;
     85                    plugBoard[letterPos] = oldPlugChar;
     86                    OnPropertyChanged("PlugBoard");
     87                    OnPropertyChanged("PlugBoard" + alphabet[letterPos]);
     88                    OnPropertyChanged("PlugBoard" + alphabet[indexofcurrentworkchar]);
     89                }
     90
     91
     92               
     93
     94
    6395
    6496                hasChanges = true;
    6597
    66                 this.workKeyCharArray = this.workKey.ToCharArray(); 
    67                
    68                 char newKeyChar=this.workKey[newIndex];
    69                
     98                this.workKeyCharArray = this.workKey.ToCharArray();
     99
     100                char newKeyChar = this.workKey[newIndex];
     101
    70102                char currentKeyChar = this.workKey[letterPos];
    71103
     
    76108                this.workKey = new string(workKeyCharArray);
    77109
    78                 this.PlugBoard= this.workKey;
     110                this.PlugBoard = this.workKey;
     111
     112                //same chage also to plugboard
     113
     114                char plugChar = plugBoard[letterPos];
     115                char newPlugChar = plugBoard[newIndex];
     116                plugBoard[newIndex] = plugChar;
     117                plugBoard[letterPos] = newPlugChar;
    79118
    80119                OnPropertyChanged("PlugBoard");
    81 
     120                OnPropertyChanged("PlugBoard" + alphabet[newIndex]);
     121                OnPropertyChanged("PlugBoard" + alphabet[letterPos]);
    82122                OnPropertyChanged("PlugBoardDisplay");
    83            
     123            }
    84124        }
    85125
     
    106146            }
    107147        }
    108         /*
    109         private int caseSensitivity = 0;
    110 
    111         [PropertySaveOrder(2)]
    112         [ContextMenu("Case Sensitivity", "If Frequency Test is feeding case sensitive analysis as input the setting should be set.", 7, DisplayLevel.Expert, ContextMenuControlType.ComboBox, null, new string[] { "Case Insensitive", "Case Sensitive" })]
    113         [TaskPane("Case Sensitivity", "If Frequency Test is feeding case sensitive analysis as input the setting should be set.", "", 7, false, DisplayLevel.Expert, ControlType.ComboBox, new string[] { "Case Insensitive", "Case Sensitive" })]
    114         public int CaseSensitivity
    115         {
    116             get { return this.caseSensitivity; }
    117             set
    118             {
    119                 if (value != caseSensitivity)
    120                 {
    121                     HasChanges = true;
    122                     caseSensitivity = value;
    123                 }
    124 
    125                 OnPropertyChanged("Case Sensitivity");
    126             }
    127         }
    128 
    129         private int language = 0;
    130 
    131         [PropertySaveOrder(3)]
    132         [ContextMenu("Language", "Choose expected language of cipher text to use the correlated built-in statistic. The option is applicable only when the inputs for frequency statistic data are not used. ", 7, DisplayLevel.Expert, ContextMenuControlType.ComboBox, null, new string[] { "English", "German", "French", "Spanish" })]
    133         [TaskPane("Language", "Choose expected language of cipher text to use the correlated built-in statistic. The option is applicable only when the inputs for frequency statistic data are not used. ", "", 7, false, DisplayLevel.Expert, ControlType.ComboBox, new string[] { "English", "German", "French", "Spanish" })]
    134         public int Language
    135         {
    136             get { return this.language; }
    137             set
    138             {
    139                 if (value != language)
    140                 {
    141                     HasChanges = true;
    142                     language = value;
    143                 }
    144 
    145                 OnPropertyChanged("Language");
    146             }
    147         }   */
     148
     149       
    148150
    149151
     
    170172
    171173
    172         [TaskPane("Plaintext Alphabet", "Displays the Plaintext alphabet", "", 29, false, DisplayLevel.Beginner, ControlType.TextBoxReadOnly)]
     174     /*   [TaskPane("Plaintext Alphabet", "Displays the Plaintext alphabet", "", 29, false, DisplayLevel.Beginner, ControlType.TextBoxReadOnly)]
    173175        public string PlaintextAlphabet
    174176        {
     
    176178           
    177179            set { } 
    178         }
     180        }*/
    179181       
    180182
     
    183185        {
    184186            get {
    185                  return this.plugBoard;
     187                return this.workKey; ;
    186188                }
    187189
     
    189191            {
    190192                hasChanges = true;
    191                 plugBoard = value;
     193                workKey = value;
     194             
    192195               OnPropertyChanged("Plugboard");
    193196            }
     
    214217        public int PlugBoardA
    215218        {
    216             get { return alphabet.IndexOf(this.alphabet[0]); }
     219            get { return alphabet.IndexOf(this.plugBoard[1]); }
    217220            set { setPlugBoard(0, value); }
    218221        }
Note: See TracChangeset for help on using the changeset viewer.