Jragon Posted July 21, 2010 Share Posted July 21, 2010 Hello People, I need a little help in making my own encryption thingy. It wont be used for sucuraty I'm just doing this so i can broden my knowage of php. What my encryption will do: QAZ = WSX WSX = EDC EDC = RFV RFV = TGB TGB = YHN . . . I was wondering if someone could point me in the right direction? Thanks Jragon Quote Link to comment https://forums.phpfreaks.com/topic/208383-help-with-cryptomethodology/ Share on other sites More sharing options...
Mchl Posted July 21, 2010 Share Posted July 21, 2010 PLM = ? Quote Link to comment https://forums.phpfreaks.com/topic/208383-help-with-cryptomethodology/#findComment-1088965 Share on other sites More sharing options...
Daniel0 Posted July 21, 2010 Share Posted July 21, 2010 How did you come up with those transformations? Did you just pick them at random? Quote Link to comment https://forums.phpfreaks.com/topic/208383-help-with-cryptomethodology/#findComment-1088983 Share on other sites More sharing options...
Mchl Posted July 21, 2010 Share Posted July 21, 2010 That seems to be qwerty keyboard layout shifted right one column. str_replace should be enough. Quote Link to comment https://forums.phpfreaks.com/topic/208383-help-with-cryptomethodology/#findComment-1088991 Share on other sites More sharing options...
Jragon Posted July 21, 2010 Author Share Posted July 21, 2010 QAZ = WSX WSX = EDC EDC = RFV RFV = TGB TGB = YHN UJM = IK OLP = QAZ Quote Link to comment https://forums.phpfreaks.com/topic/208383-help-with-cryptomethodology/#findComment-1089002 Share on other sites More sharing options...
Mchl Posted July 21, 2010 Share Posted July 21, 2010 UJM = IK Erm... Three letters encrpypted into two? Anyway, take a look into str_replace() function. Quote Link to comment https://forums.phpfreaks.com/topic/208383-help-with-cryptomethodology/#findComment-1089003 Share on other sites More sharing options...
Daniel0 Posted July 21, 2010 Share Posted July 21, 2010 strtr('qazwsx', 'wsxedc', $string); Fill out the rest yourself. http://php.net/strtr Quote Link to comment https://forums.phpfreaks.com/topic/208383-help-with-cryptomethodology/#findComment-1089005 Share on other sites More sharing options...
Jragon Posted July 21, 2010 Author Share Posted July 21, 2010 This is what i have done so far: <?php function crypty($string){ $search = array('Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm'); $replace = array('W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 'X', 'V', 'B', 'N', 'M', ' ', 'Q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a' 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm', 'q'); $subject = $string; $output = str_replace($search, $replace, $subject); return $output; } $encypt = 'Hello' echo crypty($encrypt); ?> but there an error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in C:\xampp\htdocs\cript.php on line 4 Quote Link to comment https://forums.phpfreaks.com/topic/208383-help-with-cryptomethodology/#findComment-1089137 Share on other sites More sharing options...
Mchl Posted July 21, 2010 Share Posted July 21, 2010 You've missed on comma (between 'a' and 's') Quote Link to comment https://forums.phpfreaks.com/topic/208383-help-with-cryptomethodology/#findComment-1089151 Share on other sites More sharing options...
Jragon Posted July 21, 2010 Author Share Posted July 21, 2010 Now all I'm getting is 4 q Thanks jragon I also fixed 2 errors with the $encrypt and a ; Quote Link to comment https://forums.phpfreaks.com/topic/208383-help-with-cryptomethodology/#findComment-1089154 Share on other sites More sharing options...
Daniel0 Posted July 21, 2010 Share Posted July 21, 2010 This should do what you want: <?php function encrypt($string) { return strtr($string, 'QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm', 'WERTYUIOPASDFGHJKLZXCVBNMQwertyuiopasdfghjklzxcvbnmq'); } echo encrypt('WSX'); Quote Link to comment https://forums.phpfreaks.com/topic/208383-help-with-cryptomethodology/#findComment-1089162 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.