Home>

I'm making a tool that uses C # to encrypt AES256 file contents and write them to another file.
Encryption itself has been completed successfully, but I don't know if this is properly encrypted with "AES256/CBC" = correct answer.

If i have OpenSSL etc., you can do it from the command line, but unfortunately you can't enter JAVA or PHP.
Isn't there a tool that can do "AES256/CBC file encryption by specifying a key and IV" with a Windows tool somewhere from a browser?

By the way, the code is as follows.

// Get file size
                FileInfo file = new FileInfo (files [i]);
                long size = file.Length;
                // Read area memory allocation
                byte [] readBuff = new byte [size];
                // Secure encryption area memory
                byte [] angoBuff = new byte [size];
                // read file
                // Open the file
                System.IO.FileStream fsR = new System.IO.FileStream (
                    files [i],
                    System.IO.FileMode.Open,
                    System.IO.FileAccess.Read);
                // read all the contents of the file
                fsR.Read (readBuff, 0, readBuff.Length);
                //close up
                fsR.Close ();
                // encryption
                AesManaged Aes = new AesManaged ();
                // Encryption settings
                Aes.BlockSize = 128;// 128bit
                Aes.KeySize = 128;// 128bit
                Aes.Mode = CipherMode.CBC;
                Aes.Padding = PaddingMode.PKCS7;
                Aes.Key = System.Text.Encoding.ASCII.GetBytes (@ "1234567890ABCDEF");
                Aes.IV = System.Text.Encoding.ASCII.GetBytes (@ "FEDCBA0987654321");
                // encryption
                ICryptoTransform encryptor = Aes.CreateEncryptor (Aes.Key, Aes.IV);
                // Write the encrypted information to the encryption area
                angoBuff = encryptor.TransformFinalBlock (readBuff, 0, (int) size);
                // Write file name generation
                // cut out only the file name
                String FileName = System.IO.Path.GetFileName (files [i]);
                // Write full path name assembly
                String WriteFullPath = System.IO.Path.Combine (Dest_TextBox.Text, FileName);
                // write file
                System.IO.FileStream fsW = new System.IO.FileStream (
                    WriteFullPath,
                    System.IO.FileMode.Create,
                    System.IO.FileAccess.Write);
                // Write all the contents of the byte array
                fsW.Write (angoBuff, 0, (int) angoBuff.Length);
                //close up
                fsW.Close ();
  • Answer # 1

    Is it possible to create something to decrypt and if it can be successfully decrypted, would it have been encrypted?

  • Answer # 2

    The most certain is to introduce precompiled OpenSSL (command, not library)
    I think the next point will introduce openssl in msys2/cygwin.

    An alternative is to use openssl from Git bash on Git for Windows.

    You can use the openssl command by examining it.

    If you can't install git, you can use web crypt api from your browser.

  • Answer # 3

    In verification using a different language, you will want to check the optional parameters, so you should prepare your own.

    How about creating an appropriate environment around heroku?
    If you don't need to leave the code, you can use paiza.io.

    Reference:
    Example of encryption using PHP's OpenSSL function

  • Answer # 4

    Isn't it faster to search than to ask?

    If you googled it was like this.
    How about verifying multiple sentences with short sentences?

    AES/256/EBC encryption/decryption tool

    If the results are different, I can't confirm if the original code is bad or the tool is bad ...