david212 Posted March 24, 2009 Share Posted March 24, 2009 Hello! I need help with this one. So i have password: 1234 and in this encryption it looks like: A65A65cB5A65 i mean : A65A65cB5A65 1 2 3 4 i mean 3 characters por one letter, can anyone help me how to create a code for this encryption in php? Or maybe there is some source or tutorial . Thanx Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/ Share on other sites More sharing options...
Illusion Posted March 24, 2009 Share Posted March 24, 2009 Why do you want to implement such a poor logic? you can use built-in encryption methods like md5. Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-792390 Share on other sites More sharing options...
david212 Posted March 24, 2009 Author Share Posted March 24, 2009 Why do you want to implement such a poor logic? you can use built-in encryption methods like md5. Yes, you are right but i need this one to finish my task. Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-792396 Share on other sites More sharing options...
redarrow Posted March 24, 2009 Share Posted March 24, 2009 You can not use your logic, as a real security code, in php imposable, Numbers and letters mean a lot more, then what your doing, to be classed as a security codded code like md5. your never achieve the end result like md5. There are real reason why there are built in function in php, use them. Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-792403 Share on other sites More sharing options...
david212 Posted March 24, 2009 Author Share Posted March 24, 2009 You can not use your logic, as a real security code, in php imposable, Numbers and letters mean a lot more, then what your doing, to be classed as a security codded code like md5. your never achieve the end result like md5. There are real reason why there are built in function in php, use them. i understand but i don't want this one to create a security, i just need to know how to calculate it using php, nothing more Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-792405 Share on other sites More sharing options...
Mark Baker Posted March 24, 2009 Share Posted March 24, 2009 A65A65cB5A65 1 2 3 4 So 1, 2 and 4 all encrypt to the same value. How do you decrypt? And what should 5,6,7,8,9 and 0 become when they're encrypted? Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-792413 Share on other sites More sharing options...
Illusion Posted March 24, 2009 Share Posted March 24, 2009 U can try this $array={1 => "A65", 2=> "A66",............,a=>"B65",b=>"B66",.......A=> "C65",B=>"C66",..............}; //You should define encode string for all the possible characters $string="password2"; $encode_string=""; for($i=0;i<=strlen($string);i++) { foreach($Array as $key => $value) { if($string{i}==$key) $encode_string=$encode_string+$value; } } echo $encode_string; I am telling you this is the weird way of doing things ............. Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-792416 Share on other sites More sharing options...
Yesideez Posted March 24, 2009 Share Posted March 24, 2009 If you want you can try using a different number base. Do something simple like XOR the ASCII value of the character against an 8-bit mask and then convert the resultant value to a different base, like base 6. This should be low enough to give 3 digits for each ASCII code. Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-792419 Share on other sites More sharing options...
david212 Posted March 24, 2009 Author Share Posted March 24, 2009 Thank you but there is something more, when i try to make the same 1234 encryption, so the result every time is different and this is what i don't understand. Each of them are working but are very different. Thanks for suggestions Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-792816 Share on other sites More sharing options...
david212 Posted March 24, 2009 Author Share Posted March 24, 2009 If you want you can try using a different number base. Do something simple like XOR the ASCII value of the character against an 8-bit mask and then convert the resultant value to a different base, like base 6. This should be low enough to give 3 digits for each ASCII code. Can you tell me how can i do this one? Or where i can find some tuto about this? because, i think i need this one you are telling .... Thanx Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-792820 Share on other sites More sharing options...
Mark Baker Posted March 24, 2009 Share Posted March 24, 2009 $array={'1' => "A65", '2'=> "A66",............,'a'=>"B65",'b'=>"B66",.......'A'=> "C65",'B'=>"C66",..............}; //You should define encode string for all the possible characters $string="password2"; $encode_string=""; for($i=0;i<=strlen($string);i++) { $char = $string{$i}; $encode_string .= $array[$char]; } echo $encode_string; But please enlighten us why you need to do this Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-792823 Share on other sites More sharing options...
david212 Posted March 24, 2009 Author Share Posted March 24, 2009 lol so, there is one chat, where you can create your own chat rooms, with password and access. They gave all code, room ID, also how to generate user ID, but nothing about the encryption they use to register nicknames. So i've already done the chat window with all frames to put it on my server, but with my server people onlye can login with single nicks, because i have not the encryption function and i cant create another login area for registered users. Thats all Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-792842 Share on other sites More sharing options...
laffin Posted March 24, 2009 Share Posted March 24, 2009 This is really basic, U should look at pagination which is the same process, or alternating color sequences. How to slice up 500+ messages to 25 per page. The whole thing is about keeping a counter. <?php $text="A65A65cB5A65" $key="1234" $max=3; // Three Character max per key $klen = len($key); $ctr=0; // Yes our counter; $kpos=0; // Key Position $et = ''; // Encryted Text for($i=0;$i<len($text);$i++) { $tc = substr($text,$i,1); // Grab 1 char from text $kc = substr($key,$kpos,1); // Grab 1 char from key $nc = ord($tc) ^ ord($kc); // Simple encryption logic, get ascii values and xor them $et .= $nc ; // Add it to our encrypted string $ctr++; if($ctr==$max) { have we reached our max limit $ctr=0; //reset our counter; $kpos++; // increment our key position if($kpo>=$klen)) $kpos=0; // if we are over our key, reset to beginning } } I think that shud work as is, but this is not tested. using a xor to encrypt is very simple method indeed, but it works, and ya can use the same method to decrypt the encrypted text with the same key. Good Luck Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-792938 Share on other sites More sharing options...
david212 Posted March 24, 2009 Author Share Posted March 24, 2009 This is really basic, U should look at pagination which is the same process, or alternating color sequences. How to slice up 500+ messages to 25 per page. The whole thing is about keeping a counter. <?php $text="A65A65cB5A65" $key="1234" $max=3; // Three Character max per key $klen = len($key); $ctr=0; // Yes our counter; $kpos=0; // Key Position $et = ''; // Encryted Text for($i=0;$i<len($text);$i++) { $tc = substr($text,$i,1); // Grab 1 char from text $kc = substr($key,$kpos,1); // Grab 1 char from key $nc = ord($tc) ^ ord($kc); // Simple encryption logic, get ascii values and xor them $et .= $nc ; // Add it to our encrypted string $ctr++; if($ctr==$max) { have we reached our max limit $ctr=0; //reset our counter; $kpos++; // increment our key position if($kpo>=$klen)) $kpos=0; // if we are over our key, reset to beginning } } I think that shud work as is, but this is not tested. using a xor to encrypt is very simple method indeed, but it works, and ya can use the same method to decrypt the encrypted text with the same key. Good Luck Thanx a lot . it would be something like this : <?php $text="A65A65cB5A65"; $key="1234"; $max=3; // Three Character max per key $klen = len($key); $ctr=0; // Yes our counter; $kpos=0; // Key Position $et = ''; // Encryted Text for($i=0;$i<len($text);$i++) { $tc = substr($text,$i,1); // Grab 1 char from text $kc = substr($key,$kpos,1); // Grab 1 char from key $nc = ord($tc) ^ ord($kc); // Simple encryption logic, get ascii values and xor them $et .= $nc ; // Add it to our encrypted string $ctr++; if($ctr==$max) { //have we reached our max limit $ctr=0; //reset our counter; $kpos++; // increment our key position if($kpo>=$klen) $kpos=0; // if we are over our key, reset to beginning } } ?> but it gives Fatal error: Call to undefined function len() on line 5 . Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-792980 Share on other sites More sharing options...
Mark Baker Posted March 24, 2009 Share Posted March 24, 2009 len should be strlen Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-792985 Share on other sites More sharing options...
laffin Posted March 24, 2009 Share Posted March 24, 2009 Thanks, yeah, different languages have different function names Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-793103 Share on other sites More sharing options...
david212 Posted March 25, 2009 Author Share Posted March 25, 2009 Thanx Now i understand how it works, thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-793499 Share on other sites More sharing options...
laffin Posted March 25, 2009 Share Posted March 25, 2009 Yer quite welcome, nice thing about using xor, is that u can use it in different languages. since most have this bit operator, so no extra libs required, but again its very simple technique. so isnt as hard to break as other techniques Quote Link to comment https://forums.phpfreaks.com/topic/150838-solved-need-help-with-encryption/#findComment-793710 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.