ADDON: Internal encoding functions
| From: | Faisal Nasim | Date: | Mon, 06 Mar 2000 15:56:06 +0000 |
| Subject: | ADDON: Internal encoding functions | ||
| Groups: | php.dev php.version4 | ||
| Request: | Send a blank email to php-dev+get-16450@lists.php.net to get a copy of this message | ||
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.
Attachment: [application/octet-stream] basic_functions.h.patch.2
Attachment: [application/octet-stream] basic_functions.c.patch.2
Attachment: [application/octet-stream] mycrypt.h
Attachment: [application/octet-stream] encdec.php
Attachment: [application/octet-stream] basic_functions.h.patch.2
Attachment: [application/octet-stream] basic_functions.c.patch.2
Attachment: [application/octet-stream] mycrypt.h
Attachment: [application/octet-stream] encdec.php