Q:

Read and Encryption of a PDF file in c#

I want to read a the content of a PDF file and encrypt the content using AES256 encryption and post the content(encrypted) as a base64 string.
for that i have 2 solution

read the content using a stream reader(PDF formated data) the encrypt the content and the base64 encoding, Finally send the encrypted string
Read PDF content and convert it into text then encrpt and then send

Which is the best method, If i use first method then there will be any problem for failure 
I need your opinion Please help me

A:

Your first method seems absolutely fine and I would certainly go for that approach. What you are essentially doing is simple transmitting a file from one machine to another.
If you consider this without encryption all you should be aiming to do would be to send the file stream exactly the same as you read it, this ensures the receiver gets the file in it's original state and can reliable open the file as it will be in the exact same format as it started.
Now when we consider adding encryption, all we are doing is change the raw binary data of the file. As long as we decrypt the file at the other end using the same key parameters we can be sure that we will still have the same original raw file data we started with (assuming we don't get any data loss during connection - you could add a hash check for this if desired, for example)

