Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Perl script to decode SQL ENCODE function

by Loops (Curate)
on Jul 22, 2013 at 11:36 UTC ( #1045632=note: print w/replies, xml ) Need Help??


in reply to Perl script to decode MySQL ENCODE() function

Don't see a CPAN module that does this explicitly. However, the SQL Server Documentation says there are very few characters encoded, and they're all covered by URI::Escape. So, untested but may work for ya:

use URI::Escape; print uri_unescape(">>>%5C %2F %3A %25 %3C %3E %2A %3F %5B %5D %7C<<<" +);
UGH... that is actually powershell documentation... Do you have an example of an encoded string?

Replies are listed 'Best First'.
Re^2: Perl script to decode SQL ENCODE function
by Martin90 (Sexton) on Jul 22, 2013 at 12:00 UTC
    I changed topic I was thinking about MySQL ENCODE() function. Here is example: string test after ENCODE() =>

      Could you give an actual code example, i'm not sure what you're saying. It appears from the MySQL documentation that the ENCODE function requires 2 parameters, but you haven't mentioned that. Anyway, likely the best way is to just connect to MySQL and perform the operation, for example:

      use strict; use warnings; use DBI; my $dsn = 'DBI:mysql:host=localhost'; my $dbh = DBI->connect($dsn); my $sth = $dbh->prepare("SELECT DECODE('encodedcontent', 'secretvalue' +)"); $sth->execute; my $decoded = $sth->fetchrow; print $decoded;
        There is problem: SELECT ENCODE('test','test') returns ? but SELECT DECODE('?','test') doesn't return test but ttZ what is wrong ?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1045632]
help
Chatterbox?
[Discipulus]: see you nuns and monks!
[KurtZ]: mice?
[Discipulus]: your cat is dryarian holli
[holli]: not even remotely KurtZ. i did find feathers in the garden a few times though
[holli]: yet no body
[virtualsue]: I was called upon to remove a gnawed mouse carcass from the living room this morning
holli googles dryarian just to make sure that isn't actually thing
[holli]: I mean, you never know, right?
[shmem]: good $localtime monkses
[holli]: mmh. maybe a user handle "dry arian" is a bit unfortunate? https://www. pinterest.de/ dryarian/

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2017-11-21 12:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (300 votes). Check out past polls.

    Notices?