highlander141 Posted November 13, 2013 Share Posted November 13, 2013 I am trying to use this code for simple obfuscation. But I presume nothing is returned to the function. Here's the code: <?php $source = "setup.txt"; $destination = "setup.ini"; function enc($temp) { $len = strlen($temp); for($i=0;$i<$len;$i++) { $ch = $temp[$i]; $ch = ~$ch; $temp[$i]=$ch; } } function createid($src,$dest) { $handle_1 = fopen($src, "rb"); $handle_2 = fopen($dest,"rb"); while(!feof($handle_1)) { $Byte = fgetc($handle_1); sprintf($tmp,"%c",$Byte); enc($tmp); $len = strlen($tmp); $newByte = $tmp[0]; fputs($newByte,$handle_2); } fclose($handle_1); fclose($handle_2); } createid($source,$destination); ?> Link to comment https://forums.phpfreaks.com/topic/283856-simple-obfuscation-of-txt-file/ Share on other sites More sharing options...
Barand Posted November 13, 2013 Share Posted November 13, 2013 You seem to be over-complicating $in = 'test1.txt'; $out = 'test2.txt'; /******** * obfuscate */ $txt = file_get_contents($in); $str = ''; for ($i=0, $k=strlen($txt); $i<$k; $i++) { $str .= ~$txt[$i]; } file_put_contents($out, $str); /******* * output obfuscated text */ echo '<pre><hr>'; readfile($out); /******* * output deobfuscated text */ echo '<hr>'; $txt = file_get_contents($out); for ($i=0, $k=strlen($txt); $i<$k; $i++) { echo ~$txt[$i]; } echo '</pre>'; Link to comment https://forums.phpfreaks.com/topic/283856-simple-obfuscation-of-txt-file/#findComment-1458086 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.