RE: [PHP] Maths not working.. or is it me?

2004-04-15 Thread Hawkes, Richard
I don't know what you're doing wrong... But why not use base64_encode/decode,
if all you're worried about is not storing the details in plain text...


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: 15 April 2004 10:59
To: [EMAIL PROTECTED]
Subject: [PHP] Maths not working.. or is it me?


Im trying to implement some really simply credit card encryption...
I know it's not perfect, but it's a stop gap measure until I do this 
properly... however...

To Encrypt before I put into my DB, I'm using this formula...
$encrypt = $CardNumber / ($ExpiryYear * 41.9);
(41.9 is just a random No to help encrpt the data)

To see the correct credit card No later, I'm using this formula:
$decrypt = $row[encryptedno] * $row[expiryyear] * 41.9;

The credit car No I'm testing with is:
1234123412341234
and the Exp year is 2008

However, I keep getting this result...
1.2341234123412E+15

What on earth am I doing wrong?


*
The information contained in this e-mail message is intended only for 
the personal and confidential use of the recipient(s) named above.  
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is 
strictly prohibited. If you have received this communication in error, 
please notify us immediately by e-mail, and delete the original message.
***

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


==
This message is for the sole use of the intended recipient. If you received
this message in error please delete it and notify us. If this message was
misdirected, CSFB does not waive any confidentiality or privilege. CSFB
retains and monitors electronic communications sent through its network.
Instructions transmitted over this system are not binding on CSFB until they
are confirmed by us. Message transmission is not guaranteed to be secure.
==

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Maths not working.. or is it me?

2004-04-15 Thread Ford, Mike [LSS]
On 15 April 2004 10:59, [EMAIL PROTECTED] wrote:

 Im trying to implement some really simply credit card encryption...
 I know it's not perfect, but it's a stop gap measure until I do this
 properly... however... 
 
 To Encrypt before I put into my DB, I'm using this formula...
 $encrypt = $CardNumber / ($ExpiryYear * 41.9);
 (41.9 is just a random No to help encrpt the data)
 
 To see the correct credit card No later, I'm using this formula:
 $decrypt = $row[encryptedno] * $row[expiryyear] * 41.9;
 
 The credit car No I'm testing with is:
 1234123412341234
 and the Exp year is 2008
 
 However, I keep getting this result...
 1.2341234123412E+15
 
 What on earth am I doing wrong?

Trying to express your credit card number as an integer or a float, instead
of a string.  On a 32-bit architecture, an integer can't hold a number that
big -- and a float can probably only express about 14 significant digits, so
that's no good either.  Subject to those restrictions, the result you're
getting is a correct floating point representation of your original number,
so your maths is fine.

You'd be better off keeping your CC number as a string and using one of the
string encodings or encryptions.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php