Reply to Re: [PHP] Data Enryption

Your name:

Reply:


Posted by Jason Barnett on 10/04/91 11:05

>
>
> function encrypt( $string )
> {
> $key = '&g1@8477Fg9*';

No offense intended to you sir... but why do you use a static key in
this way instead of using mcrypt? Please forgive my naivete regarding
encryption.

>
> $result = '';
>
> for( $i = 1; $i <= strlen( $string ); $i++ )
> {
> $char = substr( $string, $i - 1, 1 );
>
> $keychar = substr( $key, ( $i % strlen( $key ) ) - 1, 1 );
>
> $char = chr( ord( $char ) + ord( $keychar ) );
>
> $result .= $char;
> }
>
> return $result;
> }
>
> function decrypt( $string )
> {
> $key = '&g1@8477Fg9*';

Similar question here. I know you would need the key for decryption,
but again why not use mcrypt? Has it not been hammered out enough to
your liking?

>
> $result = '';
>
> for( $i = 1; $i <= strlen( $string ); $i++ )
> {
> $char = substr( $string, $i - 1, 1 );
>
> $keychar = substr( $key, ( $i % strlen( $key ) ) - 1, 1 );
>
> $char = chr( ord( $char ) - ord( $keychar ) );
>
> $result .= $char;
> }
>
> return $result;
> }
>
>


--
Teach a person to fish...

Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://www.php.net/manual/en/index.php
php-general archives: http://marc.theaimsgroup.com/?l=php-general&w=2

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация