Changeset 761 for trunk/CrypPlugins/SDES


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

renamed "blocksize" to "bytesToUse"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.