A bit-shuffling approach is used to avoid generating consecutive, predictable URLs. However, the algorithm is deterministic and will guarantee that no collisions will occur. The gem supports both encoding and decoding of URLs. The min_length parameter allows you to pad the URL if you want it to be a specific length.
Gemfile gem 'id_encoder', '~> 0.0.1'
install gem install id_encoder