954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Encoding problem

Hi i am new to PHP,
Can anyone fix this problem to me. i am writing a code to change password where i have already encoded a password and stored in database. and in a new changepassword form i have to do two things one is to get the oldpassword , encode it and compare it with already stored password and the second one is to get NEWPASSWORD , encode it and store it in DB. ie i need to encode two times . one is for old password and another is for new password. i succesfully encode old password and checks it to DB. But i am unable to encode a NEWPASSWORD. function encode5t($OldPassword)
{
for($i=0; $i<5;$i++)
{
$OldPassword=strrev(base64_encode($OldPassword));
}
return $OldPassword;
}
$EncOldPwd = encode5t($OldPassword);
function encode5t($NewPassword)
{
for($i=0; $i<5;$i++)
{
$NewPassword=strrev(base64_encode($NewPassword));
}
return $NewPassword;
}
$EncNEWPwd = encode5t($OldPassword);

WHEN I RUN THIS i got the error as

Fatal error: Cannot redeclare encode5t() (previously declared in C:\wamp\www\prawin\new\locations\test\admin\Changepassword.php:9) in C:\wamp\www\prawin\new\locations\test\admin\Changepassword.php on line 25
prawin@123
Light Poster
33 posts since Feb 2009
Reputation Points: 10
Solved Threads: 0
 

dont for get to base64_decode

and i think you might want to change the function name to some thing else then function encode5t for both of them


also are you includeing this file into your script more then once possibly ?

HITMANOF44th
Posting Whiz in Training
283 posts since Apr 2009
Reputation Points: 24
Solved Threads: 33
 

You don't have to write the function twice to call it twice, once is enough. Try something like this:

<?php
function encode5t($password)
		{
                  $ret = $password;
 		 for($i=0; $i<5;$i++)
  		  {
   		  $ret=strrev(base64_encode($ret)); 
  		}		
  		  return $ret;
		}

$EncOldPwd = encode5t($OldPassword);
$EncNEWPwd = encode5t($NewPassword);
?>
JRSofty
Junior Poster in Training
69 posts since Dec 2007
Reputation Points: 16
Solved Threads: 10
 

Please forgive me for replying this late, but I found this code in use on one of my client's websites.

DO NOT EVER USE THIS CODE FOR "ENCRYPTION" AND/OR "HASHING" ANYWHERE, EVER.

A) It's not encryption or hashing as it's trivially reversible
B) Longer plaintext results in longer codewords
C) Similar plaintext yields similar codewords
D) I will kill you.

alphabeta8
Newbie Poster
1 post since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You