Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

md5 encryption possibilities?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
smartywanabee
Smarty n00b


Joined: 16 Apr 2004
Posts: 3

PostPosted: Thu Aug 19, 2004 9:34 am    Post subject: md5 encryption possibilities? Reply with quote

I want to add simple encryption to URL values passed, basically I will encrypt the complete string and an hidden or secret value, when the page is opened I check the encryption value (i.e. the one containing the original string and hidden word) with the value of the new URL string,
$_SERVER['QUERY_STRING']

in PHP it may look like this..


Code:
$querystring = 'variable1=foo1&variable2=foo2;
$secretword = 'encrypt';

//Creating the query string for the link
$md5 = md5($querystring.$secretword);
$querystring = $querystring .'&hash='.$md5;
The link would then be
echo "<a href=\"test.php?".$querystring."\">click here</a><br>";


On the resulting page I would carry out the following

Code:
if ($_SERVER['QUERY_STRING']){
 //Decoding the querystring
 $querystring = $_SERVER['QUERY_STRING'];
 $data = explode('&hash=',$querystring);
 if(md5($data[0].$secretword) == $data[1]) {
   //data is valid
 } else {
   //data isn't valid - its been messed with
 }
}


This works fine in PHP, but most of my links are generated in the smarty template, so my question is if there is an easy way to carry out basic encrytion within smarty such as described above.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Aug 19, 2004 1:38 pm    Post subject: Reply with quote

You could generate your hash with a custom modifier, such as:

Code:
<a href="http://foo.com?{"foo=bar&blah=fnargle"|makehash}">click</a>


Which would render to:

Code:
<a href="http://foo.com?foo=bar&blah=fnargle&hash=ba813d572107a97e0b1f0a78fbb4b731">click</a>
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP