aximbigfan Posted February 16, 2008 Share Posted February 16, 2008 Hi, I'm codign a log viewer, and I finished up most of the core stuff, and now an doign the extra stuff. One thing is that th password for the configuration system is stored in plain text, in a .ini file. The app does checked to make sure that permission to the file is denied (from the web browser, no preventing it from explorer). Still though, I would really like just a basic 2 way encryption system. Can anyone show me how this is done? Nothing complex, just shift the position of the letters/numbers over like 5 spots or something. It will eventually need to be a bit more complex, but if someone can just show me an outline of how to do it, I'm sure I could pick it up pretty fast. I just haven't done much with this kind of thing... Thanks, Chris Link to comment https://forums.phpfreaks.com/topic/91368-very-simple-2-way-encryption/ Share on other sites More sharing options...
mysterbx Posted February 16, 2008 Share Posted February 16, 2008 http://lt2.php.net/md5 ? Link to comment https://forums.phpfreaks.com/topic/91368-very-simple-2-way-encryption/#findComment-468240 Share on other sites More sharing options...
Barand Posted February 16, 2008 Share Posted February 16, 2008 md5 is one-way An easy 2-way is str_rot13() <?php $str = 'abcde'; $encrypt = str_rot13($str); echo $encrypt . '<br/>'; // nopqr $orig = str_rot13($encrypt); echo $orig; // abcde ?> Link to comment https://forums.phpfreaks.com/topic/91368-very-simple-2-way-encryption/#findComment-468270 Share on other sites More sharing options...
Barand Posted February 16, 2008 Share Posted February 16, 2008 A slightly more complex 2-way method is to use xor bitwise operator <?php function simpleEncrypt($str, $key) { $k = strlen ($str) ; $encrypt = ''; for($i=0;$i<$k;$i++) { $encrypt .= ($str[$i]^($key)); // Xor each character with the key char } return $encrypt; } $str = 'abcde'; $key = ch r(128); $enc = simpleEncrypt($str, $key); echo $enc, '<br/>'; $orig = simpleEncrypt($enc, $key); echo $orig; ?> Link to comment https://forums.phpfreaks.com/topic/91368-very-simple-2-way-encryption/#findComment-468314 Share on other sites More sharing options...
aximbigfan Posted February 16, 2008 Author Share Posted February 16, 2008 Ok, perfect! This is exactly what I need, light, simple, easy to understand, just perfect. Thanks!!! Chris Link to comment https://forums.phpfreaks.com/topic/91368-very-simple-2-way-encryption/#findComment-468374 Share on other sites More sharing options...
aximbigfan Posted February 16, 2008 Author Share Posted February 16, 2008 I'm having trouble with this. Is there anyway to decrypt it without knowing the original string, and just knowing the already encrypted string? Thanks, Chris Link to comment https://forums.phpfreaks.com/topic/91368-very-simple-2-way-encryption/#findComment-468404 Share on other sites More sharing options...
Barand Posted February 16, 2008 Share Posted February 16, 2008 As long as you know the key character that was used $original = simpleEncrypt ($encrypted, $key); Link to comment https://forums.phpfreaks.com/topic/91368-very-simple-2-way-encryption/#findComment-468408 Share on other sites More sharing options...
Daniel0 Posted February 16, 2008 Share Posted February 16, 2008 You could also use mcrypt. Link to comment https://forums.phpfreaks.com/topic/91368-very-simple-2-way-encryption/#findComment-468419 Share on other sites More sharing options...
aximbigfan Posted February 17, 2008 Author Share Posted February 17, 2008 As long as you know the key character that was used $original = simpleEncrypt ($encrypted, $key); Bah, I'm sorry, I just wasn't thinking. Topic solved, thanks all. I'll also look at mcrypt.... Chris Link to comment https://forums.phpfreaks.com/topic/91368-very-simple-2-way-encryption/#findComment-468528 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.