Weedpacket;10905577 wrote:Really, though, I am wondering if uniqueness of long URL is necessary. If there are five million URLs, does it really matter if a couple of thousand of them are duplicates and hence can be reached by two short URLs?
I managed to get it to shorten to a 6 character code using substr, but noticed a small very minor problem with your code:
echo rtrim(strtr(base64_encode(sha1($url,true)), '+/', '-_'), '=');
Notice the - and _ in the shortcodes above? Anyways here is the code i am using to generate the shortcode:
public function generate_shortcode()
{
// generate the shortcode based on the url entered
$this->shortcode = rtrim(strtr(base64_encode(sha1($this->url,true)), '+/', '-_'), '=');
// shorten the shortcode to the desired length
$this->shortcode = substr($this->shortcode, 0, 6);
}
Any ideas?
Sincerely,
Miniature URL
script: http://miniatureurl.110mb.com