otuatail Posted February 24, 2010 Share Posted February 24, 2010 Hi. This is a strange toppic. I am looking at the reverse of substr(); I wan't to hide a string inside a larger string If the larger string is: 2d0211ce34517af44114438d14b7db94 The smaller string is: 12345678 And I want it inside the larger string starting at position 12 (zero based) , then the result would be: 2d0211ce345171234567838d14b7db94 I might want to split the smaller sting into smaller ones first. Desmond. Quote Link to comment Share on other sites More sharing options...
teamatomic Posted February 24, 2010 Share Posted February 24, 2010 The code below will do what you want. Note that this way the $sub2 will always be returned accurately no matter what the string length is. $sub2=substr("$str", 13); list($sub1,$ext)=explode(substr("$str", 13),$str); $new_string="$sub1$hidden$sub2"; If you are doing this to hide a password, dont. Look at md5 and password authentication. HTH Teamatomic Quote Link to comment Share on other sites More sharing options...
otuatail Posted February 26, 2010 Author Share Posted February 26, 2010 Thanks. No I am not using this to hide a password. I want to have encripted values in md5 format on the system for security What I anted to do was 1) get todays date and time as an md5() get todays date and time as dechex(time)) cut it up into 4 x two charecters (it is 8 long) and it can be hidden in the string at certain locations as it is invisible. this md5() string has an expiry date although you wouldent know it. Desmond Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 27, 2010 Share Posted February 27, 2010 And then how will you know you've reached the expiration date? Quote Link to comment Share on other sites More sharing options...
gamblor01 Posted February 27, 2010 Share Posted February 27, 2010 Weird -- not really sure what purpose this serves but you are definitely asking about string manipulations here (and teamatomic's answer should give you the best idea). And then how will you know you've reached the expiration date? I think he checks this by grabbing the current time and calling dechex() on that. Since he knows where the other string(s) will be located in the original md5, he can pull those out and concatenate them together. Now he has the original hex timestamp and the current hex timestamp and subtraction can tell if the md5 value is past some given threshold. Again, I'm not really sure what this is being used for but I'm intrigued anyway! Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 27, 2010 Share Posted February 27, 2010 Oh I see now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.