473,624 Members | 2,637 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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'),ENCRYP T('12345',
'mykey'),ENCRYP T('01.03', 'mykey'))

And they're read out using something along the lines of:
SELECT DECRYPT(ccName, 'mykey'), DECRYPT(ccNumbe r, '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 1405

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7947
by: wqhdebian | last post by:
As far as I know,when encrypt or decrypt ,a key must first be got,and the key is first generate by a tool or from SecurityRandom,that means I can not generate the same key with the same input.Does there is a method which can generate a same with the same input string? There is a need to transfer file between to site,and the customer wish to encrypt these files during transfering,and they want to store a string into each database at...
2
4269
by: Mark Hanford | last post by:
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'),
1
3959
by: Benoît | last post by:
Hi, I have generated two keys : "C:>openssl req -nodes -new -x509 -keyout ben.key -out ben.crt -days 3650" I try to encrypt/decrypt a string like "JOHN" with these asymetrics keys. With the following code, it works. I encrypt with the public key which is in the certificate. I decrypt with the private key. But why, the crypted message is different every time I start the programm...?
7
26773
by: Matthias S. | last post by:
Hi, I had a look at the vast information on encryption in the MSDN and got pretty confused. All I want to do is to encrypt a string into an encrypted string and later decrypt that (encrypted) string again to a human readable form. Can't be that difficult :). Could you send me please into the right direction. Thanks in advance. --
8
8168
by: Gidi | last post by:
Hi, Is there Buid-In fuction in C# that Encrypt and Decrypt strings? i have a textbox which i'm writing into file, and i want to encrypt it before writing, i'm not looking for something fancy, just for a simple Encryption and Decryption function. thanks, Gidi.
7
1957
by: C Elson | last post by:
I was hoping someone can help me out. I've searched the pages here and on numerous sites and cannot find an answer that works. I'm trying this code RC4 Encryption/Decryption http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=6646&lngWId=4 But there is no way (I can find) to clear the script afterwards. I'm trying to make it secure and when I try Back buttons I can still see the original code. I've tried all I could...
8
4269
by: toupeira23 | last post by:
Hello, I'm trying to encrypt passwords in my app. After discovering that there's no simple function to do this, I wrote a wrapper class which decodes a string using UTF8, encrypts it with TripleDES and returns a Base64-encoded string. The decryption function does the reverse, i.e. Base64-decodes the string, decrypts it with the same Key and IV, and encodes it again with UTF8. The problem is that after decrypting, the 8th character is...
4
4201
by: Islamegy® | last post by:
I give up.. I tried everything to encrypt querystring and decrypt it back but this never success.. i use RSA encryption. I always get excption when Convert fromBase64String so i tried HttpUtitlity.UrlEncode() but i got bad data Exception.. Is there anyway to work around this??
3
8264
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0 build with these methods, will appear to encrypt and decrypt, but the resulting decrypted file will be corrupted. I tried encrypting a .bmp file and then decrypting, the resulting decrypted file under .NET 2.0 is garbage, the .NET 1.1 build works...
0
8688
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7178
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6115
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4085
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2614
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1800
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.