Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:md5 [2013-03-03 12:30] – external edit 127.0.0.1notes:md5 [2019-02-10 21:07] (current) – [UPDATE (2018-04-06)] roland
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 42: Line 42:
 An alternative might be the encryption of a numeric ID and rebasing this to anything from base16 to base64. An example might follow. An alternative might be the encryption of a numeric ID and rebasing this to anything from base16 to base64. An example might follow.
  
-~~DISCUSSION|Comments~~+===== UPDATE (2018-04-06) ===== 
 + 
 +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