Welcome Guest, Not a member yet? Register   Sign In
Routes and hashed URLs
#6

I find it odd that I'm asking a question about routing and I'm getting questioned on hashing.  So here's the breakdown:

The game I'm making a calculator for has 10 "slots" for you to fill in items.  Each item and the unit itself is represented by a number like 504010010.  I get these numbers from JSON files. The GIT repository if you're curious where the data comes from (https://github.com/aEnigmatic/ffbe).

So, I have 11 "slots" so to speak to make up the URL.  The goal is to make the URL as short as possible without using a database/association table.  Otherwise I'd have really small URLs which would be awesome.

So let's take one build for example.

3020014061100000072999999999404002400408001400409004800409004800504203380504203380504203380504203380

That's the string before hashing.

4zsxryi6wthkgjdgxr6oj68w6qwvw86rie4g6rie4g8c6ttg8c6ttg8c6ttg8c6ttg

That's the string after hashing.

Here's the code how I do it:

Code:
$unit = base_convert(substr($request,0,6), 36, 10);
$right = base_convert(substr($request,6,6), 36, 10);
$left = base_convert(substr($request,12,6), 36, 10);
$head = base_convert(substr($request,18,6), 36, 10);
$body = base_convert(substr($request,24,6), 36, 10);
$acc1 = base_convert(substr($request,30,6), 36, 10);
$acc2 = base_convert(substr($request,36,6), 36, 10);
$materia1 = base_convert(substr($request,42,6), 36, 10);
$materia2 = base_convert(substr($request,48,6), 36, 10);
$materia3 = base_convert(substr($request,54,6), 36, 10);
$materia4 = base_convert(substr($request,60,6), 36, 10);

Again, the goal here is to make the URL as short as possible.  Not trying to encrypt or hide anything.

As for the routing issue: The .htaccess file I posted is how I'm doing it now without using CodeIgniter.  I was attempting to show how I was successful in doing what I wanted to do before, but trying to switch to the CI framework I was having difficulty accomplishing the same thing.
Reply


Messages In This Thread
Routes and hashed URLs - by wirikidor - 11-21-2017, 05:11 PM
RE: Routes and hashed URLs - by InsiteFX - 11-22-2017, 04:32 AM
RE: Routes and hashed URLs - by wirikidor - 11-22-2017, 08:18 AM
RE: Routes and hashed URLs - by Narf - 11-22-2017, 09:23 AM
RE: Routes and hashed URLs - by wirikidor - 11-22-2017, 09:59 AM
RE: Routes and hashed URLs - by jreklund - 11-22-2017, 05:24 AM
RE: Routes and hashed URLs - by wirikidor - 11-23-2017, 04:02 PM
RE: Routes and hashed URLs - by Narf - 11-22-2017, 11:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB