<p>So, to simplify my life I want to be able to append from 1 to 7 additional characters on the end of some jpg images my program is processing*.  These are dummy padding (fillers, etc - probably all 0x00) just to make the file size a multiple of 8 bytes for block encryption.</p>

<p>Having tried this out with a few programs, it appears they are fine with the additional characters, which occur after the <a href="http://en.wikipedia.org/wiki/JPEG#Syntax_and_structure" rel="noreferrer">FF D9 that specifies the end of the image</a> - so it appears that the file format is well defined enough that the 'corruption' I'm adding at the end shouldn't matter.</p>

<p>I can always post process the files later if needed, but my preference is to do the simplest thing possible - which is to let them remain (I'm decrypting other file types and they won't mind, so having a special case is annoying).</p>

<p>I figure with all the talk of <a href="http://en.wikipedia.org/wiki/Steganography" rel="noreferrer">Steganography</a> hullaballo years ago, someone has some input here...</p>

<p>(encryption processing by 8 byte blocks, I don't want to save pre-encrypted file size, so append 0x00 to input data, and leave them there after decoding)</p>

[{'answer_id': 50968, 'author': 'pkaeding', 'author_id': 4257, 'author_profile': 'https://Stackoverflow.com/users/4257', 'pm_score': 6, 'selected': True, 'text': '<p>No, you can add bits to the end of a jpg file, without making it unusable.  The heading of the jpg file tells how to read it, so the program reading it will stop at the end of the jpg data.</p>\n\n<p>In fact, people have hidden zip files inside jpg files by appending the zip data to the end of the jpg data.  Because of the way these formats are structured, the resulting file is valid in either format.</p>\n'}, {'answer_id': 50981, 'author': 'Rob Walker', 'author_id': 3631, 'author_profile': 'https://Stackoverflow.com/users/3631', 'pm_score': 3, 'selected': False, 'text': "<p>You can .. but the results <em>may</em> be unpredictable.  </p>\n\n<p>Even though there is enough information in the format to tell the client to ignore the extra data it is likely not a case the programmer tested for.</p>\n\n<p>A paranoid program might look at the size, notice the discrepancy and decide it won't process your file because clearly it doesn't fully understand it.  This is particularly likely when reading data from the web when random bytes in a file could be considered a security risk.</p>\n"}, {'answer_id': 51047, 'author': 'Stuart Helwig', 'author_id': 5019, 'author_profile': 'https://Stackoverflow.com/users/5019', 'pm_score': 2, 'selected': False, 'text': '<p>You can embed your data in the XMP tag within a JPEG (or EXIF or IPTC fields for that matter).\nXMP is XML so you have a fair bit of flexibility there to do you own custom stuff.</p>\n\n<p>It\'s probably not <em>the simplest thing possible</em> but putting your data here will maintain the integrity of the JPEG and require no "post processing".</p>\n\n<p>You data will then show up in other imaging software such as PhotoShop, which may not be ideal.</p>\n'}, {'answer_id': 51184, 'author': 'xanadont', 'author_id': 1886, 'author_profile': 'https://Stackoverflow.com/users/1886', 'pm_score': 0, 'selected': False, 'text': '<p>As others have stated, you have no control how programs process image files and therefore some programs may find the images valid others may not.</p>\n\n<p>However, there is a bigger issue here.  Judging by your question, I\'m deducing you\'re practicing "security through obscurity."  It\'s widely considered a very bad practice.  Use Google to find a plethora of articles about the topic.</p>\n'}]
['https://Stackoverflow.com/questions/50965', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2915/']