michael0010 Posted February 6, 2007 Share Posted February 6, 2007 Well, I decided to try and make a custom encryption for storing my passwords... I got it so that the encrypted version of the text is exactly 15 chars long... But that is not working right :/ The length changes somewhat depending on how many chars I have set it to process, and what chars I use (it converts them to ascii with ord() which probably has something to do with it). Keep in mind it's not designed to be very secure, and there is no real logic to how it works. I'll revise the way it encrypts once I get it to actually work... <?php function splitadd($string, $numrepeat) { $end = strlen($string); $len = $end; for ($intm=0; $intm<$numrepeat; $intm++) { $string = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY); $prev = $len; $len = count($string); for ($int=0; $int<$end; $int++) { $pre = $int; $char = ord($string[$int]); $string[$pre] = $char+$string[$pre]; } if (count($string) > 15) { $diff = $len-15; $count = 0; for ($int=$len; count($string)>15; $int=$int-1) { $string[$count] += $string[$int]; unset($string[$int]); if ($count < count($string)) { $count += 2; } else { $count = 0; } } } else { $diff = 15-$len; for ($int=0; $int<$diff; $int ++) { if ($string[$int+1]==0) $string[$int+1]=$string[$int]+ceil(sqrt($string[$int+2])); $cur = $string[$int]/$string[$int+1]; $string[$int] = $string[$int]-($cur+($script[$diff]/2)); $string[count($string)+1] = $cur; } } $string = implode('', $string); } return $string; } print splitadd('This is just a test', 2); ?> I'm thinking it has something to do with when it checks it length. Also, how hard would it be to bruteforce/invert? EDIT: here is an example: http://multithreading.ath.cx:24/projects/ecrypt.php Link to comment https://forums.phpfreaks.com/topic/37357-encryption-help/ Share on other sites More sharing options...
Psycho Posted February 6, 2007 Share Posted February 6, 2007 I see no reason in rebuilding the wheel. You can simply create a "customized" encryption or hash using the methods that are already available and adding a salt and combining multiple methods. Are you looking for an encryption (which can be unencrypted) or a hash? Link to comment https://forums.phpfreaks.com/topic/37357-encryption-help/#findComment-178588 Share on other sites More sharing options...
btherl Posted February 7, 2007 Share Posted February 7, 2007 "and there is no real logic to how it works" This could be your problem As to your question of how hard it is to invert, I have no idea. By using a standard encryption method you will know how hard it is to brute force or invert, as all that information will be published. Link to comment https://forums.phpfreaks.com/topic/37357-encryption-help/#findComment-178976 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.