mIRC Home    About    Download    Register    News    Help

Print Thread
mIRC $encode returns an invalid format for $decode #231421 17/04/11 06:11 PM
Joined: May 2004
Posts: 11
D
Dreadnought Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: May 2004
Posts: 11
hello, I encoded a string with $encode, and it has returned an invalid string for $decode. the string that was returned includes open parenthesis "(" which, I'm assuming makes it invalid. because the encoded string contains security sensitive data, I will be sending Khaled an IM with the decoded and encoded strings, so he can check it himself. if other people have found parenthesis in their encoded data, please post here if the encoded strings don't contain data that must be secure.

Re: mIRC $encode returns an invalid format for $decode [Re: Dreadnought] #231423 17/04/11 06:34 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
A parenthesis is a valid character of base-64 encoded data. $decode() can work with it just fine. The only caveat to that is that mIRC must have some way of knowing that the parenthesis is part of the text to be decoded and not part of the syntax of the scripting language. The only time that would be a problem is if you are manually entering the encoded text (typing/pasting it into the command line) or perhaps working with evaluation brackets, timers or scon/scid.

Example:
Originally Posted By: mIRC
//echo -a $encode(helloaaa)
(:&5L;&]A86$`
; Encoded text contains a parenthesis

//echo -a $decode($encode(helloaaa))
helloaaa
; Encoded text is taken as a parameter by $decode and returns original string

//echo 12 -a $decode((:&5L;&]A86$`)
* Invalid format: $decode
; The encoded text manually typed in causes an error as mIRC has no way to know that the parenthesis is meant as part of the parameter and not code

//var %encoded = (:&5L;&]A86$` | echo -a $decode(%encoded)
helloaaa
; By passing the encoded text to a variable (where the parenthesis means nothing special) you can then pass that variable to $decode() and get the expected result


In short, the solution is to pass the parameter in via a variable or some other means ($input() might also be useful for your purposes). This isn't a bug, just an unavoidable consequence of mIRC's scripting language not using quotes for strings to enable explicit distinction between text and code.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: mIRC $encode returns an invalid format for $decode [Re: starbucks_mafia] #232105 19/05/11 02:36 PM
Joined: Mar 2006
Posts: 393
T
The_JD Offline
Fjord artisan
Offline
Fjord artisan
T
Joined: Mar 2006
Posts: 393
To avoid stuff like this, instead of putting it in from the command line, pasting it into an input box always works.

Eg.
//echo -a $decode($?)

If you are storing it (which one would presume you are) it should work fine as long as you don't use $eval or timers (or another function that will evaluate the encoded string)


[02:16] * Titanic has quit IRC (Excess Flood)