Jump to content

need help with hashes


Monkuar

Recommended Posts

Okay, I have around 5 swords, 5 helmets, 5 boots, 2 sprite human characters.

 

problem is.. I Get the hash for each image with crc32 right? To store in my database for easy validation

 

My Canvas script lets users add items onto their main sprite character.

 

So what if user adds a sword, helmet a boot onto the main character, now javascript converts this image on the fly to base64, how would I go about validating that hash with all the hashes I have currently for my items that are stored in a database? (Server side)

 

There is no way In hell I am going to add a image onto each sprite canvas, get the hash and store them.... what IfI make 2000 more helmet image items? It would take forever. (And 200 boots) it would take ages to add 1 for each one............. There has to be a way to to check if the merged hashes contain the respectful hashes that are for each image... I hope?

Link to comment
Share on other sites

Validate and build the image server-side. Send a list of items, not a checksum of the flattened image.

 

Okay, I made it so each time they click on 1 item it ajax's check (server side) if they own it.

 

If they do, I need help on adding a sword image, onto the existing male sprite.

 

Is there a way using imagepng function where I can place the sword exactly how where I want it, on the male character and then return a full base64string to create it? I have the create functions:

 

$image = imagecreatefromstring(" NEED THE NEW LAYERDED IMAGE BASE64CODE STRING HERE");

imagealphablending($image, false);
//Create alpha channel for transparent layer
$col=imagecolorallocatealpha($image,255,255,255,127);
//Continue to keep layers transparent
imagealphablending($image,true);
//Insert the text
//Keep trnsparent when saving
imagesavealpha($image,true);

//Save & output
if(imagepng($image, "./img/nrpg/charimages/{$pun_user['id']}.png", 1)){
   header("Content-Type: image/png");
}
imagedestroy($image);
echo "<img src=img/nrpg/charimages/{$pun_user['id']}.png>";

 

which work nice.  But am I still in need of a way to grab the sword image and place it exactly by pixel ontop of the male human sprite and generate a base64 code is that possible? That must be how gaia online does it, because each time you click on a image to add to your avatar, I checked it with chrome it actually sends a request. My problem was it didn't send the request until you clicked "saved" and that gave me the vulnerability of anyone submitting any type of base64 DATA over, sure I tried to protect it checking if the user has the items/etc with jsonify array.. but they could still change the post data for the 64base.... So yeah, If you guys could help, this would be great.

 

So in a long run, I need to know how to get 1 image, (sword) ontop of another image, (my male character) by exact position.

 

Really hope someone can chime in here with me.

 

 

Link to comment
Share on other sites

I personally think you need to rethink your approach to this.

Why hashes of images?

Why do you need to validate the images?

Can't they just choose to add something, and then it gets added if they have it?

Or maybe you can let them have it (even though there should be no gui for them to do so), but if they are "hacking" they can see the stuff, but they can't save it if they don't own it.

Don't upload the image from the users... why would you do that? (if you do that)

 

When they save their character, all you need to do is to validate if they own the stuff they have saved.

If they own it, then you can on the server side with the help of php and the gd library create an image of it. The alternative of storing a copy of the image is creating one every time someone wants to view it, and that is rather waste of resources, so instead you "cache" it by only saving a new copy when the old one is replaced.

 

Hopefully this makes some kind of sense and I've understood the problem.

Link to comment
Share on other sites

I personally think you need to rethink your approach to this.

Why hashes of images?

Why do you need to validate the images?

Can't they just choose to add something, and then it gets added if they have it?

Or maybe you can let them have it (even though there should be no gui for them to do so), but if they are "hacking" they can see the stuff, but they can't save it if they don't own it.

Don't upload the image from the users... why would you do that? (if you do that)

 

When they save their character, all you need to do is to validate if they own the stuff they have saved.

If they own it, then you can on the server side with the help of php and the gd library create an image of it. The alternative of storing a copy of the image is creating one every time someone wants to view it, and that is rather waste of resources, so instead you "cache" it by only saving a new copy when the old one is replaced.

 

Hopefully this makes some kind of sense and I've understood the problem.

 

Yeah, I am changing my approach now... The hash thing is insanely dumb.

 

I am just trying to find out a way now to build the image server side.  I think imagecopy will be the best. I am looking into it as we speak and will post more when I find myself in trouble, Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.