Jump to content

Very simple 2 way encryption?


aximbigfan

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.