kailash r

kailash r

  • NA
  • 44
  • 0

File enscryprtion using twofish

Nov 16 2010 7:31 AM
Hi,

        I need to use twofish encryption method to decrypt the files. Already i have some files that encrypted using two fish. To decrypt those files currently i am using twofish algorithm from http://www.codeproject.com/KB/recipes/twofish_csharp.aspx

       But my decryption is not working, Still the bytes and contents are encrypted. I am in very urgent situation.

      My source code is,

       public static bool TwoFishEncript(string filename)
        {
            Twofish fish = new Twofish();
            fish.Mode = CipherMode.ECB;
            fish.KeySize = 256;                
            System.IO.MemoryStream ms=new MemoryStream();
            CryptoStream decStream;
            ICryptoTransform decrypt = fish.CreateDecryptor();
            CryptoStream cryptostream = new CryptoStream(ms, decrypt, CryptoStreamMode.Write);
            byte[] data = File.ReadAllBytes(filename);
            cryptostream.Write(data, 0, data.Length);
            cryptostream.Close();
            FileStream fs = new FileStream(filename.Replace(".enc", ""), FileMode.Create);
            fs.Write(data, 0, data.Length - 1);
            fs.Close();
            return true;
        }

     I have attached the twofish class file with this. This attachment is downloaded from http://www.codeproject.com/KB/recipes/twofish_csharp.aspx

Attachment: twofish_csharp.zip