title: How to decrypt ciphertext using openssl in C?
body: <p>How do I able to decrypt a cipher text which is encrypted using AES in python.</p>
  
  <p>Encrypt.py</p>
  
  <p>Using this I made cipher text using AES and concatenated that with the IV 
  and wrote that in to a file file.txt.</p>
  
  <pre><code>from Crypto.Cipher import AES
  import hashlib, os
  Plain = 'This is a string'             #String to Encrypt
  key = 'mysecretpassword'      
  #key = hashlib.md5(key).digest()       #Key
  IV = 'InitializationVector'
  IV = hashlib.md5(IV).digest()          #Initialization Vector
  print len(IV)
  Obj1 = AES.new(key, AES.MODE_CBC, IV)
  Cipher = Obj1.encrypt(Plain)           #Cipher text
  File = open('file.txt','w')
  File.write(Cipher+IV)      #Concatenated the string and IV and
                             #wrote that to a file file.txt 
  File.close()
  </code></pre>
  
  <p>Decrypt.c</p>
  
  <p>Using this now I got the Cipher text and IV from file.txt. Now how do I able 
  to decrypt the Cipher using openssl or any other libraries? </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  int main ()
  {
    char filename[] = "file.txt";
    FILE *file = fopen ( filename, "r" );
    char key[] = "mysecretpassword";
    if (file != NULL) {
      char line [1000];
      char *p = line;
      char *array = line;
      while(fgets(line,sizeof line,file)!= NULL) {
        fprintf(stdout,"%s\n",line);
        char otherString[strlen(line)-15];
        strncpy(otherString, p, strlen(line)-16);
        otherString[strlen(otherString)-1] = '\0';
        printf("%s\n", otherString);//Here I got the Encrypted string
        array=array+(strlen(array)-16);
        printf("%s\n",array);//Here I got the IV
        //Here how to decrypt the Cipher text using "IV" and "key"
      }
      fclose(file);
    }
    else {
      perror(filename);
    }
    return 0;
  }
  </code></pre>
  
  <p>Really I am a newbie. Please forgive for the errors in my question and please feel free to help me, that would be your most kindness. Thanks a lot in advance. </p>