[PHP-DEV] ADDON: Internal encoding functions From: Faisal Nasim (faisal <email protected>)
Date: 03/06/00

Hi,

Firstly Andi and Andrei,

Andi>I don't think convert_to_string_ex() can fail converting to a string.
So
Andi>you don't need that check.

My patch>+ convert_to_string_ex(str);
My patch>+
My patch>+ if ((*str)->type != IS_STRING) {
My patch>+ RETURN_FALSE;
My patch>+ }

Andrei removed those lines....

That check is also present in getenv(), and since I am new, I consulted
to neighbour functions! (I have removed this check from getenv it in this
patch).

Patch can be applied on PHP4b4-PL1 fresh copy! Tested under RH6.

I have made a COOOOL internal encryption!

NEW FUNCTIONS:

    * encode()
    * decode()
    * encdec()

    Example: (encdec.php, attached too!)

<?
 // encdec

 $x = encdec ( "faisal" , "f13" );
 print "Return: $x, Length: " . strlen ( $x );

 print "\n";

 $y = encdec ( $x , "13" );
 print "Decoded: $y, Length: " . strlen ( $y );

 print "\n\n";

 // encode

 $enc = encode ( "faisal" , "cool" );
 print "Encoded: $enc\n";

 $dec = decode ( $enc , "cool" );
 print "Decoded: $dec\n";
?>

encode() encrypts then apply the php_base64_encode() on it...
decode() applies php_base64_decode() and then decrypts it...
encdec() does not involve any calling to base*() function....

Its pretty stable and secure as far as I think!

But there is just one problem which I am stuck!

When you call decode, it prints:
base64.c(91) : Freeing 0x08113CCC (9 bytes), script=encdec.php

I really don't understand why its doing that... perhaps some
back in the decoder....

I don't have access to CVS, so either of you (or somebody) else
may apply the patches!

This is some more of my contribution to PHP!

Enjoy!

Faisal
the Whiz Kid.

  • application/octet-stream attachment: mycrypt.h

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>