Here you can pack bytes into an image ... the fun part is if you write the original file length and use the lossless image format, you can safely extract binary data later.
Packed like ARGB ...
var exefile = Directory.GetFiles(".", "*.exe").First();
var fi = new FileInfo(exefile);
var dimension = (int)Math.Sqrt((fi.Length + 1d) / 4);
using (var bitmap = new Bitmap(dimension, dimension + 2))
{
bitmap.SetPixel(0, 0, Color.FromArgb((int)fi.Length));
var buffer = new byte[fi.Length + 4 - fi.Length % 4];
Array.Copy(File.ReadAllBytes(exefile), buffer, fi.Length);
int x = 1, y = 0;
for (var offset = 0; offset < buffer.Length; offset += 4)
{
var colorValue = BitConverter.ToInt32(buffer, offset);
bitmap.SetPixel(x, y, Color.FromArgb(colorValue));
x++;
if (x >= dimension)
{
x = 0;
y++;
}
}
bitmap.Save(Path.ChangeExtension(exefile, ".png"), ImageFormat.Png);
}
Packed as a black and white binary ...
var width = (int)Math.Sqrt(fi.Length * 8);
width = width + 8 - (width % 8);
var length = (int)(fi.Length * 8 / width);
Func<byte, int, Color> getcolor =
(b, m) => (b & m) == m ? Color.Black : Color.White;
using (var bitmap = new Bitmap(width, length + 1))
{
var buffer = File.ReadAllBytes(exefile);
int x = 0, y = 0;
foreach (var @byte in buffer)
{
bitmap.SetPixel(x + 0, y, getcolor(@byte, 0x80));
bitmap.SetPixel(x + 1, y, getcolor(@byte, 0x40));
bitmap.SetPixel(x + 2, y, getcolor(@byte, 0x20));
bitmap.SetPixel(x + 3, y, getcolor(@byte, 0x10));
bitmap.SetPixel(x + 4, y, getcolor(@byte, 0x8));
bitmap.SetPixel(x + 5, y, getcolor(@byte, 0x4));
bitmap.SetPixel(x + 6, y, getcolor(@byte, 0x2));
bitmap.SetPixel(x + 7, y, getcolor(@byte, 0x1));
x += 8;
if (x >= width)
{
x = 0;
y++;
}
}
bitmap.Save(Path.ChangeExtension(exefile, ".tif"), ImageFormat.Tiff);
}
... and yes, it sounds like a noise