How do you generate a unique yet still short random string?

For url shortener project.