How to use vs2008 [VC++9](managed code) static lib in vc++6.0
<p>I have encryption decryption code in C#, VB.net and VC++ (VS 2008) and encrypted file by anyone of this can be decrypted by anyone.</p>

<p>Now the requirement is, I have to use VC++ (VS 2008) static lib file in VC++ 6.0.</p>

<p>OR suggest any other alternative to do this(without dll)</p>

<pre><code>namespace RijndaelEncDec
{

    void Rijndael::LN_EncryptFile(String^ fileSource, String^ fileDestination, String^ password)
    {
        // Declare the streams used
        // to encrypt to an in memory
        // array of bytes.

        CryptoStream^   cryptoStream;

        FileStream^ fsIn;
        FileStream^ fsOut ;

        // Declare the RijndaelManaged object
        // used to encrypt the data.
        RijndaelManaged^ RijndaelCipher;

        try
        {           
            fsIn=gcnew FileStream(fileSource, FileMode::Open, FileAccess::Read);
            fsOut = gcnew FileStream(fileDestination, FileMode::Create, FileAccess::Write);


            array&lt;Byte&gt;^  salt = gcnew array&lt;Byte&gt;(13){ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0xF1, 0xF0, 0xEE, 0x21, 0x22, 0x45 };
            Rfc2898DeriveBytes ^secretKey =gcnew Rfc2898DeriveBytes(password,salt);

            RijndaelCipher = gcnew RijndaelManaged();
            RijndaelCipher-&gt;Padding = PaddingMode::PKCS7;
            RijndaelCipher-&gt;Mode=CipherMode::CBC;
            RijndaelCipher-&gt;BlockSize=128;
            RijndaelCipher-&gt;Key = secretKey-&gt;GetBytes(32);
            RijndaelCipher-&gt;IV = secretKey-&gt;GetBytes(16);


            ICryptoTransform^ encryptor = RijndaelCipher-&gt;CreateEncryptor();
            cryptoStream = gcnew CryptoStream(fsOut, encryptor, CryptoStreamMode::Write);


            int ByteData;
            while ((ByteData=fsIn-&gt;ReadByte()) != -1)
            {
              cryptoStream-&gt;WriteByte(ByteData);
            }

          cryptoStream-&gt;FlushFinalBlock();

        }
         catch (FileNotFoundException^ ex)
            {
                if ((ex-&gt;FileName-&gt;CompareTo(fileSource) == 0) &amp;&amp; (GlobalVariableClass::logPermission == true))
                {
                    StreamWriter^ writer = gcnew StreamWriter(GlobalVariableClass::logFileLocation);
                    writer-&gt;WriteLine(ex-&gt;Message);
                    writer-&gt;Close();
                }
                if ((ex-&gt;FileName-&gt;CompareTo(fileDestination) == 0) &amp;&amp; GlobalVariableClass::logPermission == true)
                {
                    StreamWriter^ writer = gcnew StreamWriter(GlobalVariableClass::logFileLocation);
                    writer-&gt;WriteLine(ex-&gt;Message + " i.e. Input file for Encryption");
                    writer-&gt;Close();
                }

            }
         catch (Exception^ ex)
            {
                if(GlobalVariableClass::logPermission==true)
                {
                    StreamWriter^ writer = gcnew StreamWriter(GlobalVariableClass::logFileLocation);
                    writer-&gt;WriteLine(ex-&gt;Message + " During Encrypting File");
                    writer-&gt;Close();

                }


            }
        finally
        {


            // Close the streams.

            if (cryptoStream)
                cryptoStream-&gt;Close();
            if(fsIn)
                fsIn-&gt;Close();
            if(fsOut)
                fsOut-&gt;Close();
            // Clear the RijndaelManaged object.
            if (RijndaelCipher)
                RijndaelCipher-&gt;Clear();
        }

        // Return the encrypted bytes from the memory stream.
        return ;//msEncrypt-&gt;ToArray();
    }

    void Rijndael::DecryptFile(String^ fileSource, String^ fileDestination, String^ password)
    {



        array&lt;Byte&gt;^  salt = gcnew array&lt;Byte&gt;(13) { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0xF1, 0xF0, 0xEE, 0x21, 0x22, 0x45 };
        Rfc2898DeriveBytes ^secretKey =gcnew Rfc2898DeriveBytes(password,salt);       

        CryptoStream^ csDecrypt;
        StreamReader^ srDecrypt;
        FileStream^ fsIn;
        FileStream^ fsOut;

        // Declare the RijndaelManaged object
        // used to decrypt the data.
        RijndaelManaged^ RijndaelCipher;



        try
        {

            fsIn  = gcnew FileStream(fileSource, FileMode::Open, FileAccess::Read);
            fsOut = gcnew FileStream(fileDestination, FileMode::Create, FileAccess::Write);   

            RijndaelCipher = gcnew RijndaelManaged();
            RijndaelCipher-&gt;Padding = PaddingMode::PKCS7;
            RijndaelCipher-&gt;Key = secretKey-&gt;GetBytes(32);
            RijndaelCipher-&gt;IV = secretKey-&gt;GetBytes(16);

            // Create a decrytor to perform the stream transform.
            ICryptoTransform^ decryptor = RijndaelCipher-&gt;CreateDecryptor();

            // Create the streams used for decryption.

            csDecrypt = gcnew CryptoStream(fsOut, decryptor, CryptoStreamMode::Write);

            int ByteData;
            while ((ByteData=fsIn-&gt;ReadByte()) != -1)

            {

              csDecrypt-&gt;WriteByte(ByteData);

            }





        }
         catch (FileNotFoundException^ ex)
                {
                    if ((ex-&gt;FileName-&gt;CompareTo(fileSource) == 0) &amp;&amp; (GlobalVariableClass::logPermission == true))
                    {

                        StreamWriter^ writer = gcnew StreamWriter(GlobalVariableClass::logFileLocation);
                        writer-&gt;WriteLine(ex-&gt;Message + " i.e. Input file for decryption");
                        writer-&gt;Close();
                    }
                    if ((ex-&gt;FileName-&gt;CompareTo(fileDestination) == 0) &amp;&amp; GlobalVariableClass::logPermission == true)
                    {
                        StreamWriter^ writer = gcnew StreamWriter(GlobalVariableClass::logFileLocation);
                        writer-&gt;WriteLine(ex-&gt;Message + " i.e. Output file while decryption");
                        writer-&gt;Close();
                    }

                }
                catch (Exception^ ex)
                {
                    if (GlobalVariableClass::logPermission == true)
                    {
                        StreamWriter^ writer = gcnew StreamWriter(GlobalVariableClass::logFileLocation);
                        writer-&gt;WriteLine(ex-&gt;Message + " During Decrypting File");
                        writer-&gt;Close();
                    }

                }
        finally
        {
            // Clean things up.

            // Close the streams.
            if (srDecrypt)
                srDecrypt-&gt;Close();
            if (csDecrypt)
                csDecrypt-&gt;Close();

               fsIn-&gt;Close();
               fsOut-&gt;Close();


            // Clear the RijndaelManaged object.
            if (RijndaelCipher)
                RijndaelCipher-&gt;Clear();
        }

        return ;
    }

    String^ Rijndael:: ReadEncryptFileToBuffer(String^ fileSource,[System::Runtime::InteropServices::OutAttribute]  String ^% buffer,String^ password)
    {
        FileStream^ fsIn; 
        MemoryStream^ memoryStream;
        CryptoStream^ cryptoStream;
        StreamReader^ fileReader,^streamReader;
        RijndaelManaged^ RijndaelCipher;
        String^ decryptText;

         // First we are going to open the file streams
        try
        {
          RijndaelCipher = gcnew RijndaelManaged();
          RijndaelCipher-&gt;Mode = CipherMode::CBC;
          RijndaelCipher-&gt;KeySize = 256;
          RijndaelCipher-&gt;BlockSize = 128;
          RijndaelCipher-&gt;Padding = PaddingMode::PKCS7;

          fsIn = gcnew FileStream(fileSource, FileMode::Open, FileAccess::Read);
          fileReader = gcnew StreamReader(fsIn,System::Text::Encoding::Default);
          String^ cipherText = fileReader-&gt;ReadToEnd();
          array&lt;Byte&gt;^ cipherByte = System::Text::Encoding::Default-&gt;GetBytes(cipherText);



          array&lt;Byte&gt;^  salt = gcnew array&lt;Byte&gt;(13) { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0xF1, 0xF0, 0xEE, 0x21, 0x22, 0x45 };  
          Rfc2898DeriveBytes^ secretKey = gcnew Rfc2898DeriveBytes(password, salt);
          ICryptoTransform^ Decryptor = RijndaelCipher-&gt;CreateDecryptor(secretKey-&gt;GetBytes(32), secretKey-&gt;GetBytes(16));





          memoryStream = gcnew MemoryStream(cipherByte);
          cryptoStream = gcnew CryptoStream(memoryStream, Decryptor, CryptoStreamMode::Read);
          streamReader = gcnew StreamReader(cryptoStream);
          decryptText = streamReader-&gt;ReadToEnd();
          buffer = decryptText;
          Console::WriteLine(decryptText);



        }
         catch (FileNotFoundException^ ex)
        {
            if (ex-&gt;FileName-&gt;CompareTo(fileSource) == 0 &amp;&amp; GlobalVariableClass::logPermission == true)
            {

                StreamWriter^ writer = gcnew StreamWriter(GlobalVariableClass::logFileLocation);
                writer-&gt;WriteLine(ex-&gt;Message + " i.e. Input file for decryption Buffer");
                writer-&gt;Close();

            }


        }
        catch (Exception^ ex)
        {
            if (GlobalVariableClass::logPermission == true)
            {
                StreamWriter^ writer = gcnew StreamWriter(GlobalVariableClass::logFileLocation);
                writer-&gt;WriteLine(ex-&gt;Message + "i.e. During Reading Encrypting File to Decrypted Buffer");
                writer-&gt;Close();
            }

        }
        finally
        {
          if(fsIn)
          fsIn-&gt;Close();
          if(memoryStream)
          memoryStream-&gt;Close();
          if(cryptoStream)
          cryptoStream-&gt;Close();
          if(streamReader)
          streamReader-&gt;Close();

        }
        return decryptText;
    }

    void Rijndael::WriteEncFileFromDecBuffer(String^ buffer, String^ fileDestination, String^ password)
    {
        FileStream^ fsOut; 
        CryptoStream^ cryptoStream;
        StreamReader^ streamReader;

        try
        {
            RijndaelManaged^ RijndaelCipher = gcnew RijndaelManaged();
            RijndaelCipher-&gt;Mode = CipherMode::CBC;
            RijndaelCipher-&gt;KeySize = 256;
            RijndaelCipher-&gt;BlockSize = 128;
            RijndaelCipher-&gt;Padding = PaddingMode::PKCS7;

            FileStream^ fsOut = gcnew FileStream(fileDestination, FileMode::Create, FileAccess::Write);

            array&lt;Byte&gt;^  salt = gcnew array&lt;Byte&gt;(13) { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0xF1, 0xF0, 0xEE, 0x21, 0x22, 0x45 };
            array&lt;Byte&gt;^ plainText = System::Text::Encoding::Default-&gt;GetBytes(buffer);
            Rfc2898DeriveBytes^ secretKey = gcnew Rfc2898DeriveBytes(password, salt);
            ICryptoTransform^ Encryptor = RijndaelCipher-&gt;CreateEncryptor(secretKey-&gt;GetBytes(32), secretKey-&gt;GetBytes(16));

            cryptoStream = gcnew CryptoStream(fsOut, Encryptor, CryptoStreamMode::Write);

            cryptoStream-&gt;Write(plainText, 0, plainText-&gt;Length);

            cryptoStream-&gt;FlushFinalBlock();
            cryptoStream-&gt;Close();
            fsOut-&gt;Close();
        }

        catch(FileNotFoundException^ ex)
        {
            if ( GlobalVariableClass::logPermission == true)
            {

                StreamWriter^ writer = gcnew StreamWriter(GlobalVariableClass::logFileLocation);
                writer-&gt;WriteLine(ex-&gt;Message + " i.e. Output file from Dencrypted Buffer");
                writer-&gt;Close();
            }

        }
        catch(Exception^ ex)
        {
            if (GlobalVariableClass::logPermission == true)
            {
                StreamWriter^ writer = gcnew StreamWriter(GlobalVariableClass::logFileLocation);
                writer-&gt;WriteLine(ex-&gt;Message + " During Writing Encrypting File from Decrypted Buffer");
                writer-&gt;Close();

            }
        }
        finally
        {
          fsOut-&gt;Close();
          cryptoStream-&gt;Close();
          streamReader-&gt;Close();

        } 
    }
}
</code></pre>
