Results 1 to 13 of 13

Thread: [RESOLVED] Data Encryption issue

  1. #1

    Thread Starter
    Addicted Member _Yoyo's Avatar
    Join Date
    Apr 2001
    Location
    Dominican Republic
    Posts
    187

    Resolved [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

  2. #2
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    Ubuntu Haters Club
    Posts
    405

    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.

  3. #3

    Thread Starter
    Addicted Member _Yoyo's Avatar
    Join Date
    Apr 2001
    Location
    Dominican Republic
    Posts
    187

    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

  4. #4

    Thread Starter
    Addicted Member _Yoyo's Avatar
    Join Date
    Apr 2001
    Location
    Dominican Republic
    Posts
    187

    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

  5. #5
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    Ubuntu Haters Club
    Posts
    405

    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.

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Data Encryption issue

    Any reason why you haven't just set your table to the proper character set?

  7. #7

    Thread Starter
    Addicted Member _Yoyo's Avatar
    Join Date
    Apr 2001
    Location
    Dominican Republic
    Posts
    187

    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

  8. #8
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  9. #9

    Thread Starter
    Addicted Member _Yoyo's Avatar
    Join Date
    Apr 2001
    Location
    Dominican Republic
    Posts
    187

    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

  10. #10
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Data Encryption issue

    Quote 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?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  11. #11

    Thread Starter
    Addicted Member _Yoyo's Avatar
    Join Date
    Apr 2001
    Location
    Dominican Republic
    Posts
    187

    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

  12. #12
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  13. #13

    Thread Starter
    Addicted Member _Yoyo's Avatar
    Join Date
    Apr 2001
    Location
    Dominican Republic
    Posts
    187

    Re: [RESOLVED] Data Encryption issue

    Thanks!
    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
  •  



Click Here to Expand Forum to Full Width