469,599 Members | 2,868 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,599 developers. It's quick & easy.

Cache encrypt key for ENCRTPY/DECRYPT in a variable?

I've been setting up a new MySQL/PHP site which will contain store
some CC details, and have been wondering how to pass the keys.

CC's are written in a similar way to:
INSERT INTO cc (ccName, ccNumber, ccDate)
VALUES (ENCRYPT('fred smith', 'mykey'),ENCRYPT('12345',
'mykey'),ENCRYPT('01.03', 'mykey'))

And they're read out using something along the lines of:
SELECT DECRYPT(ccName, 'mykey'), DECRYPT(ccNumber, 'mykey'),
DECRYPT(ccDate, 'mykey')
FROM cc

In order to reduce the chance of the key being noticed, either by a db
error exposing the SQL query (I know my PHP should do this in a
production system, but you never know...) I've tried issuing the
following commands, but I always get errors. Is there anyway of using
variables in the EN-/DECRYPT commands?

SET @enckey='mykey';
SELECT ENCODE('fred smith', @enckey); -- causes error
SELECT DECODE('fred smith', @enckey); -- causes error

Have I missed something either RTFM or just plain silly, or can I not
do this at all?

many thanks,

Mark Hanford
Jul 19 '05 #1
0 1224

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Benoît | last post: by
7 posts views Thread by Matthias S. | last post: by
8 posts views Thread by Gidi | last post: by
7 posts views Thread by C Elson | last post: by
8 posts views Thread by toupeira23 | last post: by
4 posts views Thread by Islamegy® | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.