note 109112 deleted from function.str-replace by danbrown

From: Date: Tue, 26 Jun 2012 14:01:11 +0000
Subject: note 109112 deleted from function.str-replace by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-188846@lists.php.net to get a copy of this message
Note Submitter: chromewolf989 at hotmail dot com ---- I just started OOPHP and I modified Viam's function :) <?php /** * str_replace encryption method * * @author Viam 17-Jan-2011 05:57 [ PHP DOCS ] * @modifier Chromewolf * @purpose * Easier way to customize the way you would like to encrypt your text, * A lot easier to customize the way the text is encrypted * * 6/21/12 * Added functions so it's 10x easier for the encryption and decryption to work * Using classes and objects with __construct and function again ;) */ class encryption { private $inputdata; private $encryptdata; private $replacevars; private $outputdata; private $decryptvars; private $assignvars; public $text; public function __construct(){ $this->text = 'asdasd'; $this->encryptvars = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); $this->replacevars = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "%", "!", "@", "#", "$", "^", "&", "*","~", "+", ":", "-", "=", "?", "'", ".", "<"); $this->decryptvars = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "%", "!", "@", "#", "$", "^", "&", "*","~", "+", ":", "-", "=", "?", "'", ".", "<"); $this->assignvars = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); } public function encrypt($a) { $this->inputdata = $a; $b = str_replace($this->encryptvars, $this->replacevars, $a); echo "<br> Encrypted Text =>" . $b . '<br>'; } public function decrypt($d) { $this->outputdata = $d; $e = str_replace($this->decryptvars, $this->assignvars, $d); echo "<br> Decrypted Text =>" . $e . '<br>'; } } $obj = new encryption(); echo "<br> Regular Text => " . $obj->text . '<br>'; $obj->encrypt($obj->text); $obj->decrypt($obj->text); /* DEPRECATED - Using Classes, and objects! this is the original code + my added function - function encrypt($a) { - $inputdata = $a; - $encryptvars= array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); - $replacevars = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "%", "!", "@", "#", "$", "^", "&", "*","~", "+", ":", "-", "=", "?", "'", ".", "<"); - $b = str_replace($encryptvars, $replacevars, $a); - echo $b; - } - $pass = 'password'; - encrypt($pass); - function decrypt($d) { - $outputdata = $d; - $decryptvars = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "%", "!", "@", "#", "$", "^", "&", "*","~", "+", ":", "-", "=", "?", "'", ".", "<"); - $assignvars = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); - $e = str_replace($decryptvars, $assignvars, $d); - echo '<br>'.$e; - } - decrypt($pass); */ ?>

« previous php.notes (#188846) next »