rot13 Help :(

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

jahmin
New php-forum User
New php-forum User
Posts: 2
Joined: Mon Oct 14, 2002 10:07 pm

rot13 Help :(

Postby jahmin » Mon Oct 14, 2002 10:17 pm

Hi,

Am am pretty new to PHP, but trying really hard to learn. My problem is this. I downloaded this rot13 function

Code: Select all

<?
//******************************************
//     
// Name: rot13
// Description:Rot13ify's any string.
//     See also http://nehwon.xtn.net/rot13/
//     by Christopher Heschong
// By: PHP Code Exchange
//******************************************
    Function rot13($string) {
    for($i=0;$i<strlen($string);$i++) {
    $j=ord($string[$i]);
    if ((($j>=ord("n")) & ($j<=ord("z"))) | ($j>=ord("N")) & ($j<=ord("Z"))) {
    $j=$j-13;
    }
    elseif ((($j>=ord("a")) & ($j<=ord("m"))) | ($j>=ord("A")) & ($j<=ord("M"))) {
    $j=$j+13;
    }
    $new.=chr($j);
    }
    return($new);
    }
 ?>


and I want to put it in a form to make a rot13 translator to text/text to rot13. I have read everything, and been at this for days but cant seem to get it :cry: Can someone please give me a small working example of how this would be used in a form to help get me going in the right direction? Thanks in advance :D

Jay

Postby Jay » Tue Oct 15, 2002 5:42 am

What the hell is rot13?

DoppyNL

Postby DoppyNL » Tue Oct 15, 2002 5:49 am

rot13 is a very simple method of quickly "encrypting" some text.
to get the original text back simply apply the method again, and you get it back.
it work by swapping the first 13 letters with the last 13 letters of the alphabet.

To answer Jahmin's question:
Make a normal html-form with an input field.
You can then make the resulting page with the posted information.
use the function like this:

Code: Select all

$function_result = rot13($initial_value);

output that to you're page and you're done.

Pretty basic.

Greetz Daan

User avatar
imroue
New php-forum User
New php-forum User
Posts: 62
Joined: Fri Oct 11, 2002 6:53 am
Contact:

Postby imroue » Tue Oct 15, 2002 9:03 am

DoppyNL wrote:rot13 is a very simple method of quickly "encrypting" some text.
to get the original text back simply apply the method again, and you get it back.
it work by swapping the first 13 letters with the last 13 letters of the alphabet.


by the way.. when you use rot13, can it be read by thephp server?
so is this a way to prevent people from reading your code?

DoppyNL

Postby DoppyNL » Tue Oct 15, 2002 9:15 am

the web-server will only understand normal code, applying rot13 to it will prevent the webserver from parsing the code.

Also, I said "encrypting" (with quotes) because it is not really encrypting. When I see text wich was altered by rot13 I immediatly recognise it.
It is also very easy to get the original contents, so you should absolutely not rely on this method to keep data safe.

Greetz Daan

jahmin
New php-forum User
New php-forum User
Posts: 2
Joined: Mon Oct 14, 2002 10:07 pm

Postby jahmin » Tue Oct 15, 2002 9:20 am

Thanks alot :D

User avatar
imroue
New php-forum User
New php-forum User
Posts: 62
Joined: Fri Oct 11, 2002 6:53 am
Contact:

Postby imroue » Tue Oct 15, 2002 9:28 am

DoppyNL wrote:the web-server will only understand normal code, applying rot13 to it will prevent the webserver from parsing the code.

Also, I said "encrypting" (with quotes) because it is not really encrypting. When I see text wich was altered by rot13 I immediatly recognise it.
It is also very easy to get the original contents, so you should absolutely not rely on this method to keep data safe.

Greetz Daan


Thanks for the reply :lol:
Is there a method in php that would protect your data (for example, to keep track of passwords, credit cards..etc..) :?:

Jay

Postby Jay » Tue Oct 15, 2002 1:29 pm

PHP does have ways of encrypting things, but that's best left up to the server hardware to prevent these sorts of attacks. If you also want to encrypt data one way (ie so you can check passwords) the best way is md5, it's a one way industry standard encryption algorithm which is impossible to break!


Return to “PHP coding => General”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest