Solved

PHP simple encode/decode string

Posted on 2007-03-21
5
216 Views
Last Modified: 2012-06-27
Hi
I need something similar to md5 that will encode a string such as

"This is a test"
to
“ce114e4501d2f4e2dcea3e17b546f339”

I want to pass the encoded string as a URL parameter, at the landing page I would like to convert it back to a string. I don’t want my site visitors to know what is being passed. Md5 would suit perfectly if there was a way to convert it back to a string.  Security for the string is not an issue.

Any help would be appreciated.
0
Comment
Question by:sabecs
  • 2
  • 2
5 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 18765601
You could use uuencode and uudecode.
http://de3.php.net/manual/en/function.convert-uudecode.php
http://de3.php.net/manual/en/function.convert-uuencode.php

Or use sessions generate a random hash. store the has and the clear text calue in the session and when you get the hash back resolve it via session-lookup
0
 

Author Comment

by:sabecs
ID: 18766768
Thanks hernst42,
Sorry I should have mentioned that I need a solution using PHP 4, uudecode is only available in PHP 5 which I don't have. Also, I am not sure if sessions will work as the url is coming from another website.
0
 
LVL 9

Expert Comment

by:richdiesal
ID: 18768393
I believe the easiest way would be to use mcrypt, although you will need to download and install it.
See http://www.php.net/mcrypt for details.
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 18769613
The uudecode and uuencode functions are available in PHP4 if you install the pear-package PHP_Compat. A very simple method is to use
http://www.php.net/manual/en/function.base64-encode.php
http://www.php.net/manual/en/function.base64-decode.php
0
 

Author Comment

by:sabecs
ID: 18770678
Thanks hernst42 for your help.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question