DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Steve has posted 12 posts at DZone. View Full User Profile

Shortest Filename-friendly Hash Output

03.20.2009
| 3005 views |
  • submit to reddit
        
$str = 'digest input';
$f = __FILE__;
$hash = ('/' === $f[0]) // not Windows :)
   ? strtr(base64_encode(md5($str, true)), '+/=', '-_(')
   : md5($str);