optimized hashids implementation