Click here to Skip to main content
15,888,803 members
Home / Discussions / C#
   

C#

 
Questionmulticolumn listview Pin
Member 5903103-Feb-10 0:41
Member 5903103-Feb-10 0:41 
AnswerRe: multicolumn listview Pin
sanforjackass3-Feb-10 0:57
sanforjackass3-Feb-10 0:57 
AnswerRe: multicolumn listview Pin
OriginalGriff3-Feb-10 1:01
mveOriginalGriff3-Feb-10 1:01 
AnswerRe: multicolumn listview Pin
Ramkithepower3-Feb-10 1:22
Ramkithepower3-Feb-10 1:22 
QuestionFluentNHibernate mapping - No Persister for... Please help. Pin
Yoken3-Feb-10 0:04
Yoken3-Feb-10 0:04 
AnswerRe: FluentNHibernate mapping - No Persister for... Please help. Pin
Yoken3-Feb-10 21:07
Yoken3-Feb-10 21:07 
QuestionWork with MS office, PDF, files Pin
Hum Dum2-Feb-10 23:57
Hum Dum2-Feb-10 23:57 
Questionencryption & decryption Pin
3bood.ghzawi2-Feb-10 23:20
3bood.ghzawi2-Feb-10 23:20 
hi all, i use the following algorithms to encrypt then to decrypt a sequence of bytes, but the decryption algorithm always return an exception
<Length of the data to decrypt is invalid<
i don't know why that, both algorithms are below..,

public class CryptorEngine
    {
        static public byte[] keyArray;
        static public byte[] resultArray;

        public static void Encrypt(byte[] toEncryptArray, bool useHashing)
        {
            System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            // Get the key from config file
            string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
            if (useHashing)
            {
                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                CryptorEngine.keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();
            }
            else
                CryptorEngine.keyArray = UTF8Encoding.UTF8.GetBytes(key);

            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
            tdes.Key = keyArray;
            tdes.Mode = CipherMode.ECB;
            tdes.Padding = PaddingMode.PKCS7;

            ICryptoTransform cTransform = tdes.CreateEncryptor();
            CryptorEngine.resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
            tdes.Clear();
        }
    }

////////////////////////////////////////////////////////////////////////////

    public class DecryptorEngine
    {
        static public byte[] keyArray;
        static public byte[] resultArray;
        
        public static void Decrypt(byte[] toEncryptArray, bool useHashing)
        {
           System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            //Get your key from config file to open the lock!
            string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));

            if (useHashing)
            {
                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                DecryptorEngine.keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();
            }
            else
                DecryptorEngine.keyArray = UTF8Encoding.UTF8.GetBytes(key);

            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
            tdes.Key = keyArray;
            tdes.Mode = CipherMode.ECB;
            tdes.Padding = PaddingMode.PKCS7;

            ICryptoTransform cTransform = tdes.CreateDecryptor();
            DecryptorEngine.resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);

            tdes.Clear();
            }
    }



regards..........;
Questionapplication which allow multiple user to work on same file Pin
Sachin Pimpale2-Feb-10 23:03
Sachin Pimpale2-Feb-10 23:03 
AnswerRe: application which allow multiple user to work on same file Pin
Dan Mos2-Feb-10 23:24
Dan Mos2-Feb-10 23:24 
AnswerRe: application which allow multiple user to work on same file Pin
sanforjackass2-Feb-10 23:40
sanforjackass2-Feb-10 23:40 
QuestionInsert New Item to Combobox after Data Binding Pin
pavanig92-Feb-10 22:53
pavanig92-Feb-10 22:53 
AnswerRe: Insert New Item to Combobox after Data Binding Pin
Dan Mos2-Feb-10 23:09
Dan Mos2-Feb-10 23:09 
GeneralI want to write a simple C# compiler Pin
Fired.Fish.Gmail2-Feb-10 21:52
Fired.Fish.Gmail2-Feb-10 21:52 
AnswerRe: I want to write a simple C# compiler Pin
Nuri Ismail2-Feb-10 22:07
Nuri Ismail2-Feb-10 22:07 
GeneralRe: I want to write a simple C# compiler Pin
Fired.Fish.Gmail3-Feb-10 0:50
Fired.Fish.Gmail3-Feb-10 0:50 
GeneralRe: I want to write a simple C# compiler Pin
harold aptroot3-Feb-10 1:43
harold aptroot3-Feb-10 1:43 
GeneralRe: I want to write a simple C# compiler Pin
Fired.Fish.Gmail4-Feb-10 18:11
Fired.Fish.Gmail4-Feb-10 18:11 
GeneralRe: I want to write a simple C# compiler Pin
harold aptroot5-Feb-10 3:28
harold aptroot5-Feb-10 3:28 
Questionc# forms property Pin
ric_c+programer2-Feb-10 20:29
ric_c+programer2-Feb-10 20:29 
AnswerRe: c# forms property Pin
Calla2-Feb-10 21:25
Calla2-Feb-10 21:25 
QuestionGUI automation? Pin
Tridip Bhattacharjee2-Feb-10 19:51
professionalTridip Bhattacharjee2-Feb-10 19:51 
AnswerRe: GUI automation? Pin
Eddy Vluggen2-Feb-10 22:33
professionalEddy Vluggen2-Feb-10 22:33 
QuestionGenerate a key press Pin
DoanDucTai2-Feb-10 19:39
DoanDucTai2-Feb-10 19:39 
AnswerRe: Generate a key press [modified] Pin
Nuri Ismail2-Feb-10 21:27
Nuri Ismail2-Feb-10 21:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.