Take this hash for example:
ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad
It's too long for my purposes so I intend to use a small chunk from it, such as:
ba7816bf8f01
ba7816bf
Or similar. My intended use case:
- Video gallery on a website, represented by thumbnails. They are in random order.
- They play in the lightbox. They don't have a unique ID, only their URL is unique.
- While the lightbox is open I add something to the end of the page URL with JS History API.
//example.com/video-gallery/lightbox/ba7816bf8f01
- The suffix needs to be short and simple, definitely not a URL.
- People share the URL.
- The server can make sense of the lightbox/ba7816bf8f01 in relation to /video-gallery.
- Visiting the URL, the lightbox needs to find which video the suffix belongs to and play it.
I thought I'd SHA256 the URL of the video, use the first few characters as an ad-hoc ID. How many characters should I use from the generated hash, to considerably reduce the chance of collision?
I got the idea from URLs and Hashing by Google.
base_convert("ba7816bf8f01", 16, 36);
shorter (when it uses less possible characters) thanbase64_encode("ba7816bf8f01");
? – Collaborationist