note 109112 added to function.str-replace
| From: | chromewolf989 at hotmail dot com | Date: | Thu, 21 Jun 2012 09:28:08 +0000 |
| Subject: | note 109112 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188730@lists.php.net to get a copy of this message | ||
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);
*/
?>
----
Server IP: 79.99.203.17
Probable Submitter: 84.54.106.88
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/109112
Del: integrated -- https://master.php.net/note/delete/109112/integrated
Del: useless -- https://master.php.net/note/delete/109112/useless
Del: bad code -- https://master.php.net/note/delete/109112/bad+code
Del: spam -- https://master.php.net/note/delete/109112/spam
Del: non-english -- https://master.php.net/note/delete/109112/non-english
Del: in docs -- https://master.php.net/note/delete/109112/in+docs
Del: other reasons-- https://master.php.net/note/delete/109112
Reject -- https://master.php.net/note/reject/109112
Search -- https://master.php.net/manage/user-notes.php