web stats
Read encrypted file - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-20-2019, 01:09 AM
lam0620 lam0620 is offline
What's HL7?
 
Join Date: Jun 2019
Posts: 1
lam0620 is on a distinguished road
Default Read encrypted file

Hi,

I'd like read by JavaScript Reader the files that encrypted by C# as below code. I'm newbe Mirth Connect.
I really appreciate if you could help me.


HTML Code:
private static void EncryptFile(string inputFile, string outputFile, string skey)
{
    try
    {
        using (RijndaelManaged aes = new RijndaelManaged())
        {
            byte[] key = ASCIIEncoding.UTF8.GetBytes(skey);

            /* This is for demostrating purposes only.
             * Ideally you will want the IV key to be different from your key and you should always generate a new one for each encryption in other to achieve maximum security*/
            byte[] IV = ASCIIEncoding.UTF8.GetBytes(skey);

            using (FileStream fsCrypt = new FileStream(outputFile, FileMode.Create))
            {
                using (ICryptoTransform encryptor = aes.CreateEncryptor(key, IV))
                {
                    using (CryptoStream cs = new CryptoStream(fsCrypt, encryptor, CryptoStreamMode.Write))
                    {
                        using (FileStream fsIn = new FileStream(inputFile, FileMode.Open))
                        {
                            int data;
                            while ((data = fsIn.ReadByte()) != -1)
                            {
                                cs.WriteByte((byte)data);
                            }
                        }
                    }
                }
            }
        }
    }
    catch (Exception ex)
    {
        // failed to encrypt file
    }
}
Reply With Quote
 

Tags
encrypted file, mirth

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 12:32 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation