Ignore:
Timestamp:
Nov 20, 2008, 11:14:50 AM (13 years ago)
Author:
Danail Vazov
Message:

Added progress event + minor changes to input/OutputString

File:
1 edited

Legend:

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

    r4 r37  
    1111    [PluginInfo(false,
    1212            "Friedman Test",
    13             "Calculates the keylenght of a polyalphabetic substitusion cipher",
     13            "Calculates the probable keylenght of a polyalphabetic substitusion cipher",
    1414            "URL",
    1515            "FriedmanTest/icon.png")]
     
    2222    #region Private Variables
    2323    private int integerValue;
    24     private string stringInput;
    25     private string outputString;
     24    private string stringInput="";
     25    private string stringOutput="";
    2626    #endregion
    2727
     
    2929    #region Properties (Inputs/Outputs)
    3030
    31     [PropertyInfo(Direction.Input, "The string to be analyzed", "blablah", "",false, true, DisplayLevel.Beginner, QuickWatchFormat.Text, null)]
     31    [PropertyInfo(Direction.Input, "The string to be analyzed", "Caution: Aplaying a string, other than the one outputed from the FrequencyTest plug-in, will result in ilogical results", "",false, true, DisplayLevel.Beginner, QuickWatchFormat.Text, null)]
    3232    public string StringInput
    3333    {
     
    3838        set { stringInput = value; OnPropertyChanged("StringInput"); }
    3939    }
    40     [PropertyInfo(Direction.Output, "Integer value.", "The last generated ineteger value.", "",false , false, DisplayLevel.Beginner, QuickWatchFormat.Text, null)]
     40    [PropertyInfo(Direction.Output,"Probable key length.", "For greater accuracy, please refer to the string output.", "",false , false, DisplayLevel.Beginner, QuickWatchFormat.Text, null)]
    4141    public int IntegerValue
    4242    {
     
    5252    }
    5353
    54     [PropertyInfo(Direction.Output, "Text output", "The string after processing with the Friedman Test", "", false,false, DisplayLevel.Beginner, QuickWatchFormat.Text,null)]
    55     public string OutputString
     54    [PropertyInfo(Direction.Output, "Probable key length", "If the key length result seems to be ilogical...", "", false,false, DisplayLevel.Beginner, QuickWatchFormat.Text,null)]
     55    public string StringOutput
    5656    {
    57         get { return this.outputString; }
     57        get { return this.stringOutput; }
    5858        set
    5959        {
    60             outputString = value;
    61             OnPropertyChanged("OutputString");
     60            stringOutput = value;
     61            OnPropertyChanged("StringOutput");
    6262        }
    6363    }
     
    102102                //Edit the input from Frequency Test in order to extract the observed letter frequencies
    103103                string string1 = stringInput;
     104                string string2 = string1.Replace(Environment.NewLine, ":");
     105               
     106               
     107                string[] split = null;
     108
     109
     110
    104111               
     112                split = string2.Split(':');
    105113               
    106                
    107                 string1 = stringInput.Replace(Environment.NewLine, ":");
    108            
    109                
    110                 string[] split = null;
    111                
    112                
    113                
    114                
    115                 split = string1.Split(':');
    116114                //Now we put the needed absolute values of the letter frequencies into an array
    117115                int[] absolutevalue = new int[Convert.ToInt32(split.Length / 3)];
     
    155153                //outputString = Convert.ToString(Convert.ToDecimal(obIC));
    156154                //OnPropertyChanged("OutputString");
    157                 double Kr = 0.038; //Kappa "random" - expected coincidence rate for a uniform distribution of the same alphabet. In this case 1/26, hence we should have a 26 letter alphabet on the input.
     155                double Kr = 0.038; //Kappa "random" - expected coincidence rate for a uniform distribution of the alphabet. In this case 1/26, hence we should have a 26 letter alphabet on the input.
    158156                double Kp = 0.065; //Kappa "plain-text"
    159157                double keyLen = 0.027 * texLen / (((texLen - 1) * obIC) - (Kr * texLen) + Kp);
    160                 outputString = Convert.ToString(keyLen);
     158                stringOutput = Convert.ToString(keyLen);
    161159                OnPropertyChanged("OutputString");
     160                if (OnPluginProgressChanged != null)
     161                {
     162                    OnPluginProgressChanged(this, new PluginProgressEventArgs(texLen, texLen));
     163                }
    162164            }
    163165
Note: See TracChangeset for help on using the changeset viewer.