
Include the library (dll) attached as a reference to a .NET project and then add "using PictureCryptLibrary;" or whatever it is to use a namespace in the .NET language of your choice.
Code:
// enc PictureCrypt.Encrypt(encfile, outputfile, cipherkey); // dec PictureCrypt.Decrypt(decfile, outputfile, cipherkey);
Sorry about the source it's messy, but I wasn't really going for speed while I coded this (not visibility)
Code:
static void Encrypt(string In, string Out, byte Key)
{
HybridCipher cipher = new HybridCipher(Key);
Bitmap bmp = new Bitmap(In);
byte[] buffer = new byte[bmp.Height * bmp.Width * 4];
uint offset = 0;
fixed (byte* lpBuffer = buffer)
{
for (int x = 0; x < bmp.Width; x++)
{
for (int y = 0; y < bmp.Height; y++)
{
*((uint*)(lpBuffer + offset)) = (uint)bmp.GetPixel(x, y).ToArgb();
offset += 4;
}
}
}
byte[] chunk = new byte[100];
offset = 0;
for (int i = 0; i < buffer.Length / 100; i++)
{
Array.Copy(buffer, i * 100, chunk, 0, 100);
chunk = cipher.Encrypt(chunk);
Array.Copy(chunk, 0, buffer, i * 100, 100);
}
offset = 0;
Bitmap bmp2 = new Bitmap(bmp.Width, bmp.Height);
fixed (byte* lpBuffer = buffer)
{
for (int x = 0; x < bmp2.Width; x++)
{
for (int y = 0; y < bmp.Height; y++)
{
bmp2.SetPixel(x, y, Color.FromArgb(*((int*)(lpBuffer + offset))));
offset += 4;
}
}
}
bmp2.Save(Out);
}
Code:
static void Decrypt(string In, string Out, byte Key)
{
HybridCipher cipher = new HybridCipher(Key);
Bitmap bmp = new Bitmap(In);
byte[] buffer = new byte[bmp.Height * bmp.Width * 4];
uint offset = 0;
fixed (byte* lpBuffer = buffer)
{
for (int x = 0; x < bmp.Width; x++)
{
for (int y = 0; y < bmp.Height; y++)
{
*((uint*)(lpBuffer + offset)) = (uint)bmp.GetPixel(x, y).ToArgb();
offset += 4;
}
}
}
byte[] chunk = new byte[100];
offset = 0;
for (int i = 0; i < buffer.Length / 100; i++)
{
Array.Copy(buffer, i * 100, chunk, 0, 100);
chunk = cipher.Decrypt(chunk);
Array.Copy(chunk, 0, buffer, i * 100, 100);
}
offset = 0;
Bitmap bmp2 = new Bitmap(bmp.Width, bmp.Height);
fixed (byte* lpBuffer = buffer)
{
for (int x = 0; x < bmp2.Width; x++)
{
for (int y = 0; y < bmp.Height; y++)
{
bmp2.SetPixel(x, y, Color.FromArgb(*((int*)(lpBuffer + offset))));
offset += 4;
}
}
}
bmp2.Save(Out);
}






