Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 20:28

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Intermediate] Creating a picture cipher

Discussion on [Intermediate] Creating a picture cipher within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
[Intermediate] Creating a picture cipher

This cipher relies on the 'hybrid cipher' which can be found here;



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);
The .exe included is a program that already implements the crypto, just simply drag an drop picture(s) onto the .exe and it'll walk you through the process

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);
        }
Attached Files
File Type: rar PictureCryptLibrary.rar (2.8 KB, 4 views)
File Type: rar PictureCrypt.rar (3.6 KB, 8 views)
InfamousNoone is offline  
Reply


Similar Threads Similar Threads
[Intermediate]Server basics
05/28/2020 - CO2 Programming - 31 Replies
Hello elitepvpers members! In this topic, i will try to explain the basics of creating a conquer online private server from 'scratch' :} Before reading this i would suggest that you have to read these threads: http://www.elitepvpers.com/forum/co2-pserver-discu ssions-questions/177002-ask-yourself-before-you-st art-trying-make-server.html http://www.elitepvpers.com/forum/co2-programming/1 59269-intermediate-c-asyncsockets-server.html
[REL] Cipher encryption class (PHP)
12/27/2009 - CO2 PServer Guides & Releases - 6 Replies
Exactly as the title says, any questions will be answered and a thanks would be appreciated. #cipher.php <?php require_once 'PEAR.php'; class Crypt_Blowfish
[Tips][Intermediate]Making A UCE
07/07/2009 - Grand Chase Philippines - 11 Replies
How To Make A UCE Requirement : At least Intemediate Hacking Brains ;) Content Page: (Note that you could just press "Ctrl + F" to enable the "Find" function if you want to quickly move to a specific steps.) A_1) Updates of tutorial B_2) Programmes required
[Intermediate] Creating a strong but simple cipher
08/31/2008 - CO2 Programming - 9 Replies
Basically, here's the idea, we have a 'key' that contains every value a byte supports (0 to 255). When you encrypt a byte for instance 171 (0xAB) it creates an "x" using the first 4 bits of the byte, and "y" using the last for bits of the byte Value = 171 (0xAB) X = 10 (0xA) Y = 11 (0xB) Then in the output of the encrypt routine, it it'll fill that index as Key Here's an illustration to make it simpler; http://img120.imageshack.us/img120/3282/cipheran4 .gif



All times are GMT +1. The time now is 20:28.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.