Announcement

Collapse
No announcement yet.

Read encrypted file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
        }
    }

  • #2
    Here is js code I use for decryption. This should give you some idea.

    If you are able to decrypt, please post the results here.

    var messageBytes = Packages.org.apache.commons.ssl.OpenSSL.decrypt("a es-256-cbc",new java.lang.String("91DAEF273201E45678903FE496948DD8 ").getBytes("UTF-8"),new java.lang.String("1334967890123456").getBytes("UTF-8"), new java.lang.String(msg).getBytes("UTF-8"));
    channelMap.put('decryptedData', new java.lang.String(messageBytes, "UTF-8"));
    Best,

    Kirby

    Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

    Appliance Version 3.11.4
    Mirth Connect Version 3.8.0
    Java Version 1.6.0_45-b06
    Java (64 bit) Version 1.6.0_45-b06
    Java 7 (64 bit) Version 1.7.0_151-b15
    Java 8 (64 bit) Version 1.8.0_181-b13
    PostgreSQL Version 9.6.8

    Comment

    Working...
    X