Solved

PHP simple encode/decode string

Posted on 2007-03-21
5
214 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks hernst42 for your help.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now