Solved

PHP simple encode/decode string

Posted on 2007-03-21
5
215 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

947 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

20 Experts available now in Live!

Get 1:1 Help Now