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
Next revision
Previous revision
notes:md5 [2018-04-06 14:16]
roland [ID encryption]
notes:md5 [2019-02-10 21:07]
roland [UPDATE (2018-04-06)]
Line 7: Line 7:
 I rather wanted to create a random looking string which isn't easy to tamper with while still being "roomy" enough for millions of valid hashes with even vaster empty space between - collision resistance is the key here. One other objective is it being not too lengthy, maybe even feasible to type in if there is no link handler registered in the e-mail application. I rather wanted to create a random looking string which isn't easy to tamper with while still being "roomy" enough for millions of valid hashes with even vaster empty space between - collision resistance is the key here. One other objective is it being not too lengthy, maybe even feasible to type in if there is no link handler registered in the e-mail application.
  
-What I was looking for is something similiar to Youtube's video ID, e.g. http://www.youtube.com/watch?v=gD6slQbhF5c (damn - video not available when you're from Germany, use http://www.dailymotion.com/video/xot23_shakira-no_music instead ;-) )+What I was looking for is something similiar to Youtube's video ID, e.g. https://www.youtube.com/watch?v=WhoPPnDiY5c
  
 ===== MD5 rebase ===== ===== MD5 rebase =====
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