title: How to encrypt multiple files using RSA in C
body: <p>I have encrypted a message using RSA algorithm in C programming language. I want to encrypt multiple files which is kept in a particular folder using same key. Iam working in openSSL environment. The code that i used to encrypt a particular message is, </p>
  
  <pre><code> // Get the message to encrypt
  printf("Message to encrypt: ");
  fgets(msg, KEY_LENGTH-1, stdin);
  msg[strlen(msg)-1] = '\0';
  
  // Encrypt the message
  encrypt = malloc(RSA_size(keypair));
  int encrypt_len;
  err = malloc(130);
  if((encrypt_len = RSA_public_encrypt(strlen(msg)+1, (unsigned char*)msg, (unsigned char*)encrypt,
                                       keypair, RSA_PKCS1_OAEP_PADDING)) == -1) {
      ERR_load_crypto_strings();
      ERR_error_string(ERR_get_error(), err);
      fprintf(stderr, "Error encrypting message: %s\n", err);
      goto free_stuff;
  }
  </code></pre>
  
  <p>Now i want to use <strong>RSA algorithm</strong> to encrypt a folder which contains many files using the same public key in <strong>C</strong> </p>
  
  <p>Thanks in advance!</p>