Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Unique IDs for sorting images

Name: Anonymous 2009-09-14 3:51

I've got a problem. I been using MD5 hash as the name for images, but it's too damn long. What would you guys suggest as a shorter alternative solution?

Name: Anonymous 2009-09-14 13:13

>>23
I wouldn't do this if I were you. If you're going to use a 1-byte hash, there's probably a faster way of calculating it than md5. For example, you could do something like this :

<?php
$file = file_get_contents("image.jpg");
$hash = 0;

for ($i = 0; $i < strlen($file); $i++) {      
  $character = ord($file{$i});
  $hash = ($hash + $character) % 256;
}

$hash = ord($hash);
?>

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List