User Tools

Site Tools


notes:md5

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
notes:md5 [2019-02-10 21:03]
roland [MD5 and shorter hashing techniques]
notes:md5 [2019-02-10 21:07] (current)
roland [UPDATE (2018-04-06)]
Line 45: Line 45:
  
 After revisiting this article, I found a very detailed post about Youtube Video IDs here: [[https://​webapps.stackexchange.com/​questions/​54443/​format-for-id-of-youtube-video]] After revisiting this article, I found a very detailed post about Youtube Video IDs here: [[https://​webapps.stackexchange.com/​questions/​54443/​format-for-id-of-youtube-video]]
 +
 +===== UPDATE (2019-02-10) =====
 +
 +Tom wrote:
 +
 +[...] After scouring the web and stack overflow it was by far the simplest solution I could find.  One thing I might suggest is working from the raw md5 output (rather than re-packing it) and remove undesirable characters. ​ For example, here is the function I came up with for my needs:
 +
 +<​code>​
 +
 +function tinymd5($str,​ $length) { // convert md5 to ~base(64 - count($remove)) and truncate to $length
 +    // remove vowels to prevent undesirable words and similarly + / which may be problematic
 +    $remove = array('​a',​ '​e',​ '​i',​ '​o',​ '​u',​ '​A',​ '​E',​ '​I',​ '​O',​ '​U',​ '​+',​ '/'​);​
 +    return str_pad(substr(str_replace($remove,​ '',​ base64_encode(md5($str,​ TRUE))), 0, $length), $length, '​='​);​
 +}
 +
 +</​code>​
notes/md5.txt ยท Last modified: 2019-02-10 21:07 by roland