function - How can I convert a query string into a a shorter alphanumeric string (and convert it back again) in PHP? -


i want store query string of current url shorter alphanumeric string ability convert original query string.

for example: inputtype=timeline&count=50&hashtag=%23li&filterspecifiedhashtag=1&filterhashtagsend=1&filterscreennames=1&extracturl=1&deshortifyurl=1&filterurls=1

i want able use resultant alphanumeric string filename.

i want avoid using mysql or storing values in text file.

is there way convert alphanumeric string being able convert original query string? not knowledgeable hashing wondering whether kind of "two way hashing" technique work?

what seeking not hash - since hash one-way function in common case. here possible solution - use both base64 encryption , parameters map, able shorter file name because you'll not store parameters names, values:

class holder {    const name_param_delimier = '|';     public static function getparametersmap()    {       return [         0 => 'count',         1 => 'deshortifyurl',         2 => 'extracturl',         3 => 'filterhashtagsend',         4 => 'filterscreennames',         5 => 'filterspecifiedhashtag',         6 => 'filterurls',         7 => 'hashtag',         8 => 'inputtype',       ];    }     public static function getparamsbyname($sname, $breturnasarray=true)    {       $rgparams = @array_combine(self::getparametersmap(), explode(self::name_param_delimier, base64_decode($sname)));       if(!is_array($rgparams))       {          return null;       }       return $breturnasarray?$rgparams:http_build_query($rgparams);    }     public static function getnamebyparams($squery)    {       parse_str($squery, $rgparams);       ksort($rgparams);       return base64_encode(join(self::name_param_delimier, array_values($rgparams)));    } } $squery = 'inputtype=timeline&count=50&hashtag=%23li&filterspecifiedhashtag=1&filterhashtagsend=1&filterscreennames=1&extracturl=1&deshortifyurl=1&filterurls=1';  $sname  = holder::getnamebyparams($squery); $rgdata = holder::getparamsbyname($sname); var_dump($sname); //ntb8mxwxfdf8mxwxfdf8i2xpfhrpbwvsaw5l var_dump($rgdata); 

also note base64 produce "=" symbols - not sure allowed on file systems (i'm using reiser, it's ok in case)


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -