diff options
-rw-r--r-- | index.php | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -221,7 +221,7 @@ function nl2br_escaped($html) | |||
221 | return str_replace('>','>',str_replace('<','<',nl2br($html))); | 221 | return str_replace('>','>',str_replace('<','<',nl2br($html))); |
222 | } | 222 | } |
223 | 223 | ||
224 | /* Returns the small hash of a string | 224 | /* Returns the small hash of a string, using RFC 4648 base64url format |
225 | eg. smallHash('20111006_131924') --> yZH23w | 225 | eg. smallHash('20111006_131924') --> yZH23w |
226 | Small hashes: | 226 | Small hashes: |
227 | - are unique (well, as unique as crc32, at last) | 227 | - are unique (well, as unique as crc32, at last) |
@@ -233,10 +233,7 @@ function nl2br_escaped($html) | |||
233 | function smallHash($text) | 233 | function smallHash($text) |
234 | { | 234 | { |
235 | $t = rtrim(base64_encode(hash('crc32',$text,true)),'='); | 235 | $t = rtrim(base64_encode(hash('crc32',$text,true)),'='); |
236 | $t = str_replace('+','-',$t); // Get rid of characters which need encoding in URLs. | 236 | return strtr($t, '+/', '-_'); |
237 | $t = str_replace('/','_',$t); | ||
238 | $t = str_replace('=','@',$t); | ||
239 | return $t; | ||
240 | } | 237 | } |
241 | 238 | ||
242 | // In a string, converts urls to clickable links. | 239 | // In a string, converts urls to clickable links. |