> // then I place the message that is to be encrypted in a file
>
> $fp = fopen("plaintxt", "w+");

This won't scale up too well...  You would be better off to use pipe (|) to
shove it to the PGP program.  Actually, that's still not such a hot idea...
Anybody who can do "ps auxwwww" could catch the occasional credit card that
way.  Use popen instead of system.  OTOH, if you are using SSL, as you
should for this, and there exists a user with a login who can do "ps" that
you don't inherently trust, you're already in deeper trouble than system()
versus popen()...  Still, better safe than sorry, and popen won't be that
much harder than system()

> fputs($fp, $msg);

This adds a line break at the end, though.

And it maybe "escapes" the embedded newlines on the assumption that you
intend to use fgets()to read the "line" back in.  Also, if you have
MagicQuotes Whatsit turned on (not GPC, the other one) that will also maybe
attempt to add backslashes to the data.

Use fwrite to get *exactly* what you put in, and make sure php.ini doesn't
have the second MagicQuotes thingie turned on.

I've never turned it on, so don't remember what it's called. Magic Quotes
Runtime?  Yeah, that's it...

> // fyi ... if at this point, if I were to open the file plaintxt
> // all of my line breaks would still be there

Plus an extra one at the end. :-)

> // next I encrypt the data and write it to a file called crypted
>
> system("/usr/local/bin/pgpe -r [EMAIL PROTECTED] -o crypted -a
> plaintxt");
>
> unlink("plaintxt");
>
> // now ... if at this point I were to open the file crypted and decrypt
> it
> // I would get my message in a long line with squares where every break
> should be

If all else fails, fopen that and read it char by char printing out the
ASCII codes of any non-alphabetic chars and figure out what those little
squares are.  Your text editor shows all sorts of unprintable characters as
little squares.  You need to figure out which character it actually is.

(Or get a better editor that will tell you, or find out how to make your
editor tell you.)

> // here's the method I use to get this crypted data added to my log file
>
> $fd = fopen("crypted", "r");
>
> $msg_crypted = fread($fd, filesize("crypted"));
>
> fclose($fd);
>
> unlink("crypted");
>
> $order_log = fopen("order_log", "a");
>
> fwrite($order_log, $msg_crypted);
>
> fclose($order_log);
>
> So, if anyone can help me figure out a way to keep these line breaks in
> place all the way through to decryption, I would be VERY appreciative.
> I know this is possible ... because, if I take the same message from my
> code and place it in a text editor ... encrypt and decrypt it using my
> desktop PGP software ... all of the line breaks remain intact.

--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to