Activity Stream
48,167 MEMBERS
62899 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 7 of 7
  1.     
    #1
    Member
    Website's:
    UmNotaBlogger.com

    Exclamation Trying 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;
    ?>
    and here's a result:
    Code: 
    Original:
    abcdefghijklmnopqrstuvwxyz0123456789
    Scrambled:
    iopzxcvbnmaldfghjklqrertyuiopzxcvbnm
    as you can see, there are no numerics in the scrambled string... any help?
    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

  2.   Sponsored Links

  3.     
    #2
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    Using 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;
    ?>

  4.     
    #3
    Respected 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;
    ?>

  5.     
    #4
    Member
    Website's:
    UmNotaBlogger.com
    Quote Originally Posted by soft2050 View Post
    Using 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;
    ?>
    I also need to unscramble the scrambled string later on... thats why I didn't go for str_shuffle

    Quote Originally Posted by Lock Down View Post
    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;
    ?>
    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

  6.     
    #5
    Respected 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 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;
    ?>

  7.     
    #6
    Member
    Website's:
    UmNotaBlogger.com
    okay... 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_256md5($encryptionpass), $keyMCRYPT_MODE_CBCmd5(md5($encryptionpass))));

    echo 
    "Original:<br/>";
    echo 
    $key."<br/>";
    echo 
    "Scrambled:<br/>";
    echo 
    $result;
    ?>
    to decrypt, you just have to use this:
    PHP Code: 
    rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256md5($encryptionpass), base64_decode($result), MCRYPT_MODE_CBCmd5(md5($encryptionpass))), "\0"); 
    anyways, I'll be using the one lock down gave as that is the one I was looking for!

  8.     
    #7
    Respected Member
    You are welcome.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Hiring] PHP Programmer to create script
    By ChaoscripT in forum Services
    Replies: 0
    Last Post: 12th Apr 2012, 08:49 PM
  2. Anyone can create script like this?
    By MediaStar in forum Web Application/Script Support
    Replies: 12
    Last Post: 25th Feb 2012, 12:03 PM
  3. [Hiring] Looking for any one who can create script as like Adf.ly
    By Pettrious in forum Completed Transactions
    Replies: 10
    Last Post: 21st Feb 2012, 09:00 PM
  4. Pornbb problem ... can't create new thread
    By Lie8 in forum Technical Help Desk Support
    Replies: 7
    Last Post: 5th Jul 2011, 05:59 PM
  5. Could someone create a little script for me please :)
    By pisoj1 in forum Community Cooperative
    Replies: 10
    Last Post: 5th Nov 2010, 10:22 AM

Tags for this Thread

BE SOCIAL