Click here to Skip to main content
14,922,433 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi, anyone knows how to split an image into pieces, using javascript? I need to encrypt and decrypt that picture into pieces so that hacker will have a problem getting the information,

is there any way to split the image by default to uneven shape? like a jig-saw puzzle form, due to security reasons, as I doing a project on that. Example: a random image, split into many parts via code, and the size must be uneven, like bigger square and smaller square, so that it will be harder for hacker to put back the pieces as one.

http://www.google.com.sg/imgres?q=split+image+into+tiles&um=1&hl=en&sa=N&biw=1680&bih=949&tbm=isch&tbnid=mm-8EYBUItGF-M:&imgrefurl=https://wiki.openmrs.org/display/docs/Google%2BMaps%2BImage%2BViewer%2BModule&docid=s7uskvnQ0eQ2HM&imgurl=https://wiki.openmrs.org/download/attachments/3346707/Googlemaps-heterochromiacat_2.jpg%253Fversion%253D1%2526modificationDate%253D1282171110000&w=384&h=288&ei=BbBeT5SXO6utiQeeqY3cBw&zoom=1&iact=rc&dur=238&sig=118284517343590822152&page=2&tbnh=142&tbnw=189&start=40&ndsp=48&ved=1t:429,r:22,s:40&tx=155&ty=94


~
an example, but the squares are of different size, larger/smaller, (have to do this by coding) do you know to do?

thanks~



an example, but the squares are of different size, larger/smaller, (have to do this by coding) do you know to do?

thanks~
Posted
Comments
Sergey Alexandrovich Kryukov 13-Mar-12 23:59pm
   
Interesting idea but bad from the security standpoint. Please see my answer.
--SA

1 solution

Bad idea. If you need real security, you cannot use JavaScript as it is totally placed on the client side, so it can be easily read and analyzed off-line. After that, one could design and implement an automated work-around solution based on the same data available to your script. In other words, the rough idea is that: looking at your script fully available to the client, one can create an anti-script for it and mimic a human operator to crack your "protection" against a robot.

Therefore, the right solution should be based on server-side code. Besides, in this case, graphic manipulations is way easier to implement and debug, because this is .NET. You can develop and debug the main engine using a desktop application, which is way faster and easier, and then move it to your Web application.

Your .NET solution on the server-side needs only one graphics library to accomplish this task: System.Drawing; please see:
http://msdn.microsoft.com/en-us/library/system.drawing.aspx[^].

—SA
   
v2
Comments
Joel Tan Wei Shan 14-Mar-12 2:36am
   
I am currently doing a project , whereby, I have to do captcha, where instead of words, we have to encrypt the image into uneven proportion, so that the user can decrypt it back to the original image,

works like a captcha just that its picture form instead, are you able to help me please?
   
Thank you; this is how I understood it in first place. Interesting part of project and the idea, by the way, but JavaScript is not acceptable.

Now, what help do you expect? I think I gave you the basic idea. It might need hours to design it all, which I hardly would be able to afford. The project looks interesting my may require really good amount of work, even on .NET. Could you focus on some particular concerns?
--SA
Joel Tan Wei Shan 14-Mar-12 6:02am
   
Lets say, one picture, it split into 9 different blocks like http://www.codeproject.com/KB/graphics/bitmap.aspx?msg=1102868

One block of it has to split into 3 different layers of pixel, so if one layer is missing the image will not be as clear as the original as 1 layer of pixel is gone,

Do you know how to do the pixel part?
Sergey Alexandrovich Kryukov 14-Mar-12 12:37pm
   
Yes, you can use System.Drawing.Bitmap and System.Drawing.Bitmap.LockBits, and System.Runtime.InteropServices.Marshal;

http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.lockbits.aspx
see a code sample here:
http://msdn.microsoft.com/en-us/library/5ey6h79d.aspx

--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900