Changeset 761


Ignore:
Timestamp:
Oct 21, 2009, 9:31:36 AM (12 years ago)
Author:
kopal
Message:

renamed "blocksize" to "bytesToUse"

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPluginBase/Control/IControlCost.cs

    r717 r761  
    3030      double calculateCost(byte[] text);
    3131
    32       int getBlocksize();
     32      int getBytesToUse();
    3333  }
    3434}
  • trunk/CrypPlugins/CostFunction/CostFunction.cs

    r717 r761  
    129129            if (this.InputText is Object && this.stopped == false)
    130130            {
    131                 int blocksize = 0;
     131                int bytesToUse = 0;
    132132                try
    133133                {
    134                     blocksize = int.Parse(settings.Blocksize);
     134                    bytesToUse = int.Parse(settings.BytesToUse);
    135135                }
    136136                catch (Exception ex)
    137137                {
    138                     GuiLogMessage("Entered blocksize is not an integer: " + ex.Message, NotificationLevel.Error);
     138                    GuiLogMessage("Entered bytesToUse is not an integer: " + ex.Message, NotificationLevel.Error);
    139139                    return;
    140140                }
    141141                byte[] array;
    142142
    143                 if (blocksize > 0)
    144                 {
    145                     //Create a new Array of size of Blocksize if needed
    146                     array = new byte[blocksize];
    147                     for (int i = 0; i < blocksize && i < this.InputText.Length; i++)
     143                if (bytesToUse > 0)
     144                {
     145                    //Create a new Array of size of bytesToUse if needed
     146                    array = new byte[bytesToUse];
     147                    for (int i = 0; i < bytesToUse && i < this.InputText.Length; i++)
    148148                    {
    149149                        array[i] = InputText[i];
     
    323323        }
    324324
    325         public int getBlocksize()
     325        public int getBytesToUse()
    326326        {
    327327            try
    328328            {
    329                 return int.Parse(((CostFunctionSettings)this.plugin.Settings).Blocksize);
     329                return int.Parse(((CostFunctionSettings)this.plugin.Settings).BytesToUse);
    330330            }
    331331            catch (Exception ex)
    332332            {
    333                 throw new Exception("Entered blocksize is not an integer: " + ex.Message);
     333                throw new Exception("Entered bytesToUse is not an integer: " + ex.Message);
    334334            }
    335335        }
     
    356356        ///
    357357        /// Cost function can be set by CostFunctionSettings
    358         /// This algorithm uses a blocksize which can be set by CostFunctionSettings
    359         /// If blocksize is set to 0 it uses the whole text
     358        /// This algorithm uses a bytesToUse which can be set by CostFunctionSettings
     359        /// If bytesToUse is set to 0 it uses the whole text
    360360        ///
    361361        /// </summary>
     
    364364        public double calculateCost(byte[] text)
    365365        {
    366             int blocksize = 0;
     366            int bytesToUse = 0;
    367367            try
    368368            {
    369                 blocksize = int.Parse(((CostFunctionSettings)this.plugin.Settings).Blocksize);
     369                bytesToUse = int.Parse(((CostFunctionSettings)this.plugin.Settings).BytesToUse);
    370370            }
    371371            catch (Exception ex)
    372372            {
    373                 throw new Exception("Entered blocksize is not an integer: " + ex.Message);
     373                throw new Exception("Entered bytesToUse is not an integer: " + ex.Message);
    374374            }
    375375            byte[] array;
    376376
    377             if (blocksize > 0)
    378             {
    379                 //Create a new Array of size of Blocksize if needed
    380                 array = new byte[blocksize];
    381                 for (int i = 0; i < blocksize && i < text.Length; i++)
     377            if (bytesToUse > 0)
     378            {
     379                //Create a new Array of size of bytesToUse if needed
     380                array = new byte[bytesToUse];
     381                for (int i = 0; i < bytesToUse && i < text.Length; i++)
    382382                {
    383383                    array[i] = text[i];
  • trunk/CrypPlugins/CostFunction/CostFunctionSettings.cs

    r693 r761  
    3030        private bool hasChanges = false;
    3131        private int functionType=0;
    32         private String blocksize = "256";
     32        private String bytesToUse = "256";
    3333        #endregion
    3434       
     
    4444        }
    4545
    46         [TaskPane("Blocksize", "Which blocksize should be used for calculating?", null, 4, false, DisplayLevel.Beginner, ControlType.TextBox)]
    47         public String Blocksize
     46        [TaskPane("Bytes to use", "Which amount of bytes should be used for calculating?", null, 4, false, DisplayLevel.Beginner, ControlType.TextBox)]
     47        public String BytesToUse
    4848        {
    4949            get
    5050            {
    51                 return blocksize;
     51                return bytesToUse;
    5252            }
    5353            set
    5454            {
    55                 blocksize = value;
    56                 OnPropertyChanged("Blocksize");
     55                bytesToUse = value;
     56                OnPropertyChanged("bytesToUse");
    5757            }
    5858        }
  • trunk/CrypPlugins/KeySearcher/KeySearcher.cs

    r744 r761  
    276276
    277277                int size = Pattern.initKeyIteration(settings.Key);
    278                 int blocksize = CostMaster.getBlocksize();
     278                int bytesToUse = CostMaster.getBytesToUse();
    279279                string key;
    280280                int counter = 0;
     
    287287                {                   
    288288                    key = Pattern.getKey();                   
    289                     byte[] decryption = sender.Decrypt(ControlMaster.getKeyFromString(key), blocksize);
     289                    byte[] decryption = sender.Decrypt(ControlMaster.getKeyFromString(key), bytesToUse);
    290290
    291291                    valueKey = new ValueKey();
  • trunk/CrypPlugins/SDES/SDES.cs

    r744 r761  
    579579        /// </summary>
    580580        /// <param name="key">key</param>
    581         /// <param name="blocksize">blocksize</param>
     581        /// <param name="bytesToUse">bytesToUse</param>
    582582        /// <returns>encrypted text</returns>
    583         public byte[] Encrypt(byte[] key, int blocksize)
    584         {
    585             return execute(key, blocksize, 0);
     583        public byte[] Encrypt(byte[] key, int bytesToUse)
     584        {
     585            return execute(key, bytesToUse, 0);
    586586        }
    587587
     
    590590        /// </summary>
    591591        /// <param name="key">key</param>
    592         /// <param name="blocksize">blocksize</param>
     592        /// <param name="bytesToUse">bytesToUse</param>
    593593        /// <returns>decrypted text</returns>
    594         public byte[] Decrypt(byte[] key, int blocksize)
    595         {
    596             return execute(key, blocksize, 1);
     594        public byte[] Decrypt(byte[] key, int bytesToUse)
     595        {
     596            return execute(key, bytesToUse, 1);
    597597        }
    598598
     
    636636        /// </summary>
    637637        /// <param name="key">key</param>
    638         /// <param name="blocksize">blocksize</param>
     638        /// <param name="bytesToUse">bytesToUse</param>
    639639        /// <returns>encrypted/decrypted text</returns>
    640         private byte[] execute(byte[] key, int blocksize, int action)
     640        private byte[] execute(byte[] key, int bytesToUse, int action)
    641641        {
    642642            byte[] output;
    643             if (blocksize > 0)
    644                 output = new byte[blocksize];
     643            if (bytesToUse > 0)
     644                output = new byte[bytesToUse];
    645645            else
    646646                output = new byte[plugin.InputStream.Length];
     
    649649            {
    650650                plugin.InputChanged = false;
    651                 input = new byte[blocksize];
     651                input = new byte[bytesToUse];
    652652
    653653                byte[] buffer = new byte[1];
     
    655655                int i = 0;
    656656                CryptoolStream inputstream = plugin.InputStream;
    657                 while ((inputstream.Read(buffer, 0, 1)) > 0 && i < blocksize)
     657                while ((inputstream.Read(buffer, 0, 1)) > 0 && i < bytesToUse)
    658658                {
    659659                    input[i] = buffer[0];
     
    665665            if (((SDESSettings)plugin.Settings).Mode == 0 && action == 0)
    666666            {                               
    667                 output = ecb.encrypt(input, key, blocksize);
     667                output = ecb.encrypt(input, key, bytesToUse);
    668668            }
    669669            else if(((SDESSettings)plugin.Settings).Mode == 1 && action == 0)
    670670            {               
    671                 output = cbc.encrypt(input, key, Tools.stringToBinaryByteArray(enc.GetString(plugin.InputIV)),blocksize);
     671                output = cbc.encrypt(input, key, Tools.stringToBinaryByteArray(enc.GetString(plugin.InputIV)),bytesToUse);
    672672            }           
    673673            else if(((SDESSettings)plugin.Settings).Mode == 0 && action == 1)
    674674            {
    675                 output = ecb.decrypt(input, key,blocksize);
     675                output = ecb.decrypt(input, key,bytesToUse);
    676676            }
    677677            else if (((SDESSettings)plugin.Settings).Mode == 1 && action == 1)
    678678            {
    679                 output = cbc.decrypt(input, key, Tools.stringToBinaryByteArray(enc.GetString(plugin.InputIV)), blocksize);
     679                output = cbc.decrypt(input, key, Tools.stringToBinaryByteArray(enc.GetString(plugin.InputIV)), bytesToUse);
    680680            }   
    681681            return output;
     
    17821782        ///using CipherBlockChaining
    17831783        ///
    1784         /// blocksize tells the algorithm how many bytes it has to encrypt
    1785         /// blocksize = 0 => encrypt all
    1786         public byte[] encrypt(byte[] input, byte[] key, byte[] vector, [Optional, DefaultParameterValue(0)] int blocksize)
     1784        /// bytesToUse tells the algorithm how many bytes it has to encrypt
     1785        /// bytesToUse = 0 => encrypt all
     1786        public byte[] encrypt(byte[] input, byte[] key, byte[] vector, [Optional, DefaultParameterValue(0)] int bytesToUse)
    17871787        {
    17881788            int until = input.Length;           
    17891789
    1790             if (blocksize < until && blocksize > 0)
    1791                 until = blocksize;
     1790            if (bytesToUse < until && bytesToUse > 0)
     1791                until = bytesToUse;
    17921792
    17931793            byte[] output = new byte[until];
     
    18381838        ///using CipherBlockChaining
    18391839        ///
    1840         /// blocksize tells the algorithm how many bytes it has to encrypt
    1841         /// blocksize = 0 => encrypt all
    1842         public byte[] decrypt(byte[] input, byte[] key, byte[] vector, [Optional, DefaultParameterValue(0)] int blocksize)
     1840        /// bytesToUse tells the algorithm how many bytes it has to encrypt
     1841        /// bytesToUse = 0 => encrypt all
     1842        public byte[] decrypt(byte[] input, byte[] key, byte[] vector, [Optional, DefaultParameterValue(0)] int bytesToUse)
    18431843        {
    18441844
    18451845            int until = input.Length;
    18461846           
    1847             if (blocksize < until && blocksize > 0)
    1848                 until = blocksize;
     1847            if (bytesToUse < until && bytesToUse > 0)
     1848                until = bytesToUse;
    18491849
    18501850            byte[] output = new byte[until];
     
    19141914        ///using ElectronicCodeBookMode
    19151915        ///
    1916         /// blocksize tells the algorithm how many bytes it has to encrypt
    1917         /// blocksize = 0 => encrypt all
    1918         public byte[] encrypt(byte[] input, byte[] key, [Optional, DefaultParameterValue(0)] int blocksize)
     1916        /// bytesToUse tells the algorithm how many bytes it has to encrypt
     1917        /// bytesToUse = 0 => encrypt all
     1918        public byte[] encrypt(byte[] input, byte[] key, [Optional, DefaultParameterValue(0)] int bytesToUse)
    19191919        {
    19201920
    19211921            int until = input.Length;
    19221922
    1923             if(blocksize < until && blocksize > 0)
    1924                 until = blocksize;
     1923            if(bytesToUse < until && bytesToUse > 0)
     1924                until = bytesToUse;
    19251925
    19261926            byte[] output = new byte[until];
     
    19691969        ///using ElectronicCodeBookMode
    19701970        ///
    1971         /// blocksize tells the algorithm how many bytes it has to decrypt
    1972         /// blocksize = 0 => encrypt all
    1973         public byte[] decrypt(byte[] input, byte[] key, [Optional, DefaultParameterValue(0)] int blocksize)
     1971        /// bytesToUse tells the algorithm how many bytes it has to decrypt
     1972        /// bytesToUse = 0 => encrypt all
     1973        public byte[] decrypt(byte[] input, byte[] key, [Optional, DefaultParameterValue(0)] int bytesToUse)
    19741974        {
    19751975            int until = input.Length;
    19761976
    1977             if (blocksize < until && blocksize > 0)
    1978                 until = blocksize;
     1977            if (bytesToUse < until && bytesToUse > 0)
     1978                until = bytesToUse;
    19791979           
    19801980            byte[] output = new byte[until];
Note: See TracChangeset for help on using the changeset viewer.