Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: Perl script to decode SQL ENCODE function

by Martin90 (Sexton)
on Jul 22, 2013 at 20:14 UTC ( [id://1045716]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Perl script to decode SQL ENCODE function
in thread Perl script to decode MySQL ENCODE() function

There is problem: SELECT ENCODE('test','test') returns ?üÔÚ but SELECT DECODE('?üÔÚ','test') doesn't return test but ttZ¦ô what is wrong ?
  • Comment on Re^4: Perl script to decode SQL ENCODE function

Replies are listed 'Best First'.
Re^5: Perl script to decode SQL ENCODE function
by Loops (Curate) on Jul 22, 2013 at 20:36 UTC

    Really can't say. Maybe a character encoding problem if you're copy-and-pasting. The following code works here:

    use strict; use warnings; use DBI; my $db = DBI->connect('DBI:mysql:host=localhost'); my ($encoded) = $db->selectrow_array("SELECT ENCODE('ToBeHidden', 'sec +retvalue')"); my ($decoded) = $db->selectrow_array("SELECT DECODE('$encoded', 'secre +tvalue')"); print $decoded; # prints --> ToBeHidden
      Yes, my mistake I copied binary string, shame ;) Thanks for help.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1045716]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-23 20:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found