Results 1 to 7 of 7
-
27th Mar 2012, 06:48 PM #1OPMemberWebsite's:
UmNotaBlogger.comTrying to create a scrambling script but got into a problem...
Here's the coding... I am using "preg_replace"
PHP Code:<?php
$key = $_SERVER['QUERY_STRING'];
$characters = 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/','/0/','/1/','/2/','/3/','/4/','/5/','/6/','/7/','/8/','/9/');
$scrambles = array('0','1','2','3','4','5','6','7','8','9','a','s','d','f','g','h','j','k','l','q','w','e','r','t','y','u','i','o','p','z','x','c','v','b','n','m');
$result = preg_replace($characters, $scrambles, $key);
echo "Original:<br/>";
echo $key."<br/>";
echo "Scrambled:<br/>";
echo $result;
?>
Code:Original: abcdefghijklmnopqrstuvwxyz0123456789 Scrambled: iopzxcvbnmaldfghjklqrertyuiopzxcvbnm
Mr. Goodie2Shoes Reviewed by Mr. Goodie2Shoes on . Trying to create a scrambling script but got into a problem... Here's the coding... I am using "preg_replace" <?php $key = $_SERVER; $characters = 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/','/0/','/1/','/2/','/3/','/4/','/5/','/6/','/7/','/8/','/9/'); $scrambles = array('0','1','2','3','4','5','6','7','8','9','a','s','d','f','g','h','j','k','l','q','w','e','r','t','y','u','i','o','p','z','x','c','v','b','n','m'); $result = Rating: 5
-
27th Mar 2012, 06:54 PM #2Respected MemberWebsite's:
DL4Everything.com Soft2050.inUsing Regular Expression is not a good choice to do that. You could use str_shuffle to scramble a string
http://php.net/manual/en/function.str-shuffle.php
PHP Code:<?php
$key = $_SERVER['QUERY_STRING'];
$result = str_shuffle($key);
echo "Original:<br/>";
echo $key."<br/>";
echo "Scrambled:<br/>";
echo $result;
?>
-
27th Mar 2012, 09:54 PM #3Respected Member
It's happening because it changes multiple times during the preg_replace.
try this:
PHP Code:
<?php
$key = $_SERVER['QUERY_STRING'];
// used for testing
// $key = 'abcdefghijklmnopqrstuvwxyz0123456789';
$characters = 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/','/0/','/1/','/2/','/3/','/4/','/5/','/6/','/7/','/8/','/9/');
$scrambles = array('0','1','2','3','4','5','6','7','8','9','a','s','d','f','g','h','j','k','l','q','w','e','r','t','y','u','i','o','p','z','x','c','v','b','n','m');
$result = '';
$ctr =0;
$one = 1;
while ($ctr < strlen($key)) {
$k = substr($key,$ctr,1);
$out = preg_replace($characters[$ctr], $scrambles[$ctr], $k, $one);
$result .= $out;
$ctr++; }
echo "Original:<br/>";
echo $key."<br/>";
echo "Scrambled:<br/>";
echo $result;
?>
-
28th Mar 2012, 01:54 PM #4OPMemberWebsite's:
UmNotaBlogger.comI also need to unscramble the scrambled string later on... thats why I didn't go for str_shuffle
oh... awesome!
Thanks man!
---------- Post added at 07:54 PM ---------- Previous post was at 10:25 AM ----------
okay lockdown.... I got a problem... this doesn't work when I use this:
Code:Original: mnacrGfjzbGl1uj Scrambled: mnacrGfjzbGi1u
-
28th Mar 2012, 02:47 PM #5Respected Member
Here this will work except to reverse capitals to capitals you need to put them in your tables. If not change the str_replace to str_ireplace .
PHP Code:<?php
$key = $_SERVER['QUERY_STRING'];
$characters = 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','0','1','2','3','4','5','6','7','8','9');
$scrambles = array('0','1','2','3','4','5','6','7','8','9','a','s','d','f','g','h','j','k','l','q','w','e','r','t','y','u','i','o','p','z','x','c','v','b','n','m');
$result = '';
$ctr = $one = 0;
while ($ctr < strlen($key))
{
$k = substr($key,$ctr,1);
$ctr1 = $one = 0;
while ( $one < 1 and $ctr1 < count($characters) )
{ $out = str_replace($characters[$ctr1], $scrambles[$ctr1], $k, $one); $ctr1++; }
$result .= $out;
$ctr++;
}
echo "Original:<br/>";
echo $key."<br/>";
echo "Scrambled:<br/>";
echo $result;
?>
-
28th Mar 2012, 03:35 PM #6OPMemberWebsite's:
UmNotaBlogger.comokay... I'll check it out... again thanks for the help
---------- Post added at 09:35 PM ---------- Previous post was at 09:29 PM ----------
ooo... it works! thanks man!
anyways, to help others, I've found another algorithm:
PHP Code:<?php
$key = $_SERVER['QUERY_STRING'];
$encryptionpass = '[a random string here...]';
$result = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($encryptionpass), $key, MCRYPT_MODE_CBC, md5(md5($encryptionpass))));
echo "Original:<br/>";
echo $key."<br/>";
echo "Scrambled:<br/>";
echo $result;
?>
PHP Code:rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($encryptionpass), base64_decode($result), MCRYPT_MODE_CBC, md5(md5($encryptionpass))), "\0");
-
28th Mar 2012, 06:39 PM #7Respected Member
You are welcome.
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
[Hiring] PHP Programmer to create script
By ChaoscripT in forum ServicesReplies: 0Last Post: 12th Apr 2012, 08:49 PM -
Anyone can create script like this?
By MediaStar in forum Web Application/Script SupportReplies: 12Last Post: 25th Feb 2012, 12:03 PM -
[Hiring] Looking for any one who can create script as like Adf.ly
By Pettrious in forum Completed TransactionsReplies: 10Last Post: 21st Feb 2012, 09:00 PM -
Pornbb problem ... can't create new thread
By Lie8 in forum Technical Help Desk SupportReplies: 7Last Post: 5th Jul 2011, 05:59 PM -
Could someone create a little script for me please :)
By pisoj1 in forum Community CooperativeReplies: 10Last Post: 5th Nov 2010, 10:22 AM
themaPoster - post to forums and...
Version 5.23 released. Open older version (or...