|
-
Jun 27th, 2008, 11:15 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Data Encryption issue
Hi!
I'm using special characters in my page so to avoid convertion issues, I save the data to MySQL using base64_encode() and to display it back, I use base64_decode. Everything works perfect.
The problem is that I need to search that data. For example, if I have something saved like "The typical Hello World", encrypted looks like VGhlIHR5cGljYWwgSGVsbG8gV29ybGQ=.
1.- I can't search ... WHERE field LIKE '%Hello%'... because it won't find anything.
2.- I can't search:
PHP Code:
$search_srt = base64_encode($_POST['search']);
... 'WHERE field LIKE '% " . $search_str . "%'" ...
Because "Hello" ecrypted is "SGVsbG8=" and won't match either.
Any ideas?
The biggest man you ever did see was once just a baby.
Bob Marley
-
Jun 27th, 2008, 02:01 PM
#2
Hyperactive Member
Re: Data Encryption issue
Either don't encrypt the data or get all of the results out of the database and then search through the records (in PHP) in a loop.
» Twitter: @rudi_visser : Website: www.rudiv.se «
If Apple fixes security flaws, they are heralded as proactive. If Microsoft fixes a security flaw, they finally got around to fixing their buggy OS.
-
Jun 27th, 2008, 03:21 PM
#3
Thread Starter
Addicted Member
Re: Data Encryption issue
What will happen when the database reaches the 500000 records? Taking them all out for a loop would not be funny...
The biggest man you ever did see was once just a baby.
Bob Marley
-
Jun 27th, 2008, 03:42 PM
#4
Thread Starter
Addicted Member
Re: Data Encryption issue
I thought of encryptnig word for word, but can anyone tell me if the word "White" alone encrypted using base64 would be the same as the one in the sentence "The White House"?
The biggest man you ever did see was once just a baby.
Bob Marley
-
Jun 27th, 2008, 05:04 PM
#5
Hyperactive Member
Re: Data Encryption issue
No of course not, if there's actually going to be 500000 records, and since the encryption is not simply for data comparison, I really suggest the non-encrypted route.......
» Twitter: @rudi_visser : Website: www.rudiv.se «
If Apple fixes security flaws, they are heralded as proactive. If Microsoft fixes a security flaw, they finally got around to fixing their buggy OS.
-
Jun 28th, 2008, 12:04 AM
#6
Re: Data Encryption issue
Any reason why you haven't just set your table to the proper character set?
-
Jun 30th, 2008, 07:30 AM
#7
Thread Starter
Addicted Member
Re: Data Encryption issue
Thanks for answering. I've done it, but for some reason it won't work. the charset is set tu utf8 just like my pages. I've used utf8_encode/decode functions and nothing. Any reason?
The biggest man you ever did see was once just a baby.
Bob Marley
-
Jul 1st, 2008, 04:13 AM
#8
Re: Data Encryption issue
Base64 is not an encryption system, its a number system similar to decimal and hexadecimal. It should not be mistaken for encryption either as decoding it is a trivial task.
-
Jul 1st, 2008, 08:44 AM
#9
Thread Starter
Addicted Member
Re: Data Encryption issue
I had to do the word by word in order for it to work. thanks all!
The biggest man you ever did see was once just a baby.
Bob Marley
-
Jul 1st, 2008, 08:47 AM
#10
Re: Data Encryption issue
 Originally Posted by _Yoyo
I had to do the word by word in order for it to work. thanks all!
How about not using base64 at all? Can you upload a sample of the data inside a file?
-
Jul 1st, 2008, 08:58 AM
#11
Thread Starter
Addicted Member
Re: [RESOLVED] Data Encryption issue
Spanish characters: ñÑ, áÁ, éÉ, íÍ, óÓ, úÚ.
Everytime a save them to mysql it goes like greek or something. Not to mention when trying to display them on the page. Using base64 helps keep them the way they're suppose to but the searching thing... I've set the charset on both the pages and the DB, tried utf8_encode and nothing.
The biggest man you ever did see was once just a baby.
Bob Marley
-
Jul 1st, 2008, 12:08 PM
#12
Re: [RESOLVED] Data Encryption issue
When the data is transferred it "should not" be modified by the browser. That means the data you receive at your will be identical to the data on the client side. I do also believe that those characters exist in the ISO-8859-1 standard so you should not have a problem with storing them as it is also the default in MySql.
Have a look at this good article on MySql and character encodings: http://dev.mysql.com/tech-resources/...1/unicode.html
-
Jul 1st, 2008, 04:19 PM
#13
Thread Starter
Addicted Member
Re: [RESOLVED] Data Encryption issue
The biggest man you ever did see was once just a baby.
Bob Marley
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|