How do I generate random 12 character char for URL of a page for the record in the database like how youtube does it with 11 characters <https://www.youtube.com/watch?v=kDjirnJcanw>

I want it to be unique for each entry in the database and consist of letters of upper and lower case, numbers and maybe (if not bad for security) even special characters.