News:

The "Support Requests" forum is now viewable by guests.

Main Menu

I must be retarded because I keep screweing up str_replace()

Started by sixthcrusifix, June 15, 2006, 05:22:55 AM

Previous topic - Next topic

brainiac744

You COULD do that, or you could go ahead and leave it as one string, and then split it up in php (adding in seperators). You're right about it possibly incorrectly parsing though...

What I was suggesting would be to split the string up first by using something like

str_split();

http://us3.php.net/manual/en/function.str-split.php

Then you can match the values in the array without having to worry about things getting crossed.

sixthcrusifix

#16
Quote from: brainiac744 on June 21, 2006, 06:19:33 PM
You COULD do that, or you could go ahead and leave it as one string, and then split it up in php (adding in seperators). You're right about it possibly incorrectly parsing though...

What I was suggesting would be to split the string up first by using something like

str_split();

http://us3.php.net/manual/en/function.str-split.php

Then you can match the values in the array without having to worry about things getting crossed.

oh I have been using str_split but not in that way, hmmm. .

I have some useless code and I have some valid stuff and I think i need to clean it up first.

I changed my working version so that the seperators are .'s on the left and numbers on the right. So that 32, 34.55, 67, 89.1 would look possibly like this: .324.34.554.674.89.14
and it pases correctly, giving incorrect decoding only when particular seeds are used (Specifically hello and qwerty, loll).

But that's just a hokey guise. I could even make the number seperator generated through the seed to, but I much like your idea better, I want it to be extremly difficult to even be able to see the seperations in letters.

I was also thinking of not using str_replace and instead simply splitting the original message into an array, and then somehow combinign it into a number array and creating a band new array with each wordjavascript:void(0);
Insert Quote coded and then imploding it into the new coded message, I just haven't figured out how I'd get it back. (I just re-read what you wrote and realised that this is what you suggested LOLL I'll look into it)

Thanks :D
___________________________________________________________

I decided to try to completely rewrite the whole thing from scratch and I messed up somewhere. The values change drastically depending on teh seed but . . . all of the letters have the exact same value . . .? ? ? I've actually included my code this time just don't laugh at the simplicity of it, I intend on cleaning it up and making a crypt class.


<?php
//the variabel message is really the seed

function seed($MSG,$message,$what){
$MSG strtolower($MSG);
//$message = strtolower($message);
  
$new md5($message);
  
$new.= strrev($new);
  
$new str_split($new);
  
$var1 strlen($message);
  
$var2 $var1-($var1*.90);
  
$var2 floor($var2);
  
$S = array(".",":");
  
$vowels = array("a","e","i","o","u","A","E","I","O","U");
$stringarray str_split($MSG);
$str_size count($stringarray);
$startnums = array();
$I 0;$II 0;
$seed_size count($new);

$chartonum = array
(
"q"=>'10',"w"=>'35',
"e"=>'11',"r"=>'34',
"t"=>'12',"y"=>'33',
"u"=>'13',"i"=>'32',
"o"=>'14',"p"=>'15',
"a"=>'16',"s"=>'17',
"d"=>'18',"f"=>'19',
"g"=>'20',"h"=>'21',
"j"=>'22',"k"=>'23',
"l"=>'24',"z"=>'25',
"x"=>'26',"c"=>'27',
"v"=>'28',"b"=>'29',
"n"=>'30',"m"=>'31',
);
$multiplier 0;
$ii 0;
while(
$ii<$seed_size){
     if(
is_numeric($new[$ii])){
 $multiplier+=$new[$ii];

     }
 
$ii++;
}

/////////////////////////
 
while($I<$str_size){
   while(
$II<$seed_size){
     if(
is_numeric($new[$II]))
     { 
     
$value = (round(($new[$II]*(.1*$multiplier)),1)); 
     }else
     {
     
$value $chartonum[$new[$II]];
     }
 $II++;
   } 
 
$startnums[$I]=$value;
 
$I++;
 } 
 
$search $stringarray;
$replace $startnums;
$subject $stringarray;
//
 
if($what==1){
 
$new_msg str_replace($search,$replace,$subject);
 }elseif(
$what==2){
 
$new_msg str_replace($replace,$search,$subject); 
 }
 
$new_msg implode('',$new_msg);

return 
$new_msg
}
Visite me website at http://www.sixthcrusifix.com