Creating a short unique string for each unique long string

Posted by king.net on Stack Overflow See other posts from Stack Overflow or by king.net
Published on 2012-09-08T15:22:24Z Indexed on 2012/09/08 15:38 UTC
Read the original article Hit count: 373

Filed under:
|
|
|

I'm trying to create a url shortener system in c# and asp.net mvc. I know about hashtable and I know how to create a redirect system etc. The problem is indexing long urls in database. Some urls may have up to 4000 character length, and it seems it is a bad idea to index this kind of strings. The question is: How can I create a unique short string for each url? for example MD5 can help me? Is MD5 really unique for each string?

NOTE: I see that Gravatar uses MD5 for emails, so if each email address is unique, then its MD5 hashed value is unique. Is it right? Can I use same solution for urls?

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc