mIRC Home    About    Download    Register    News    Help

Print Thread
#138394 30/12/05 05:31 PM
Joined: Jul 2005
Posts: 56
W
whoami Offline OP
Babel fish
OP Offline
Babel fish
W
Joined: Jul 2005
Posts: 56
Hi, please is there a way i can decode a $based string??
for example..
//echo -a $base(test,10,16)
this will returns me 77F5

is there a way to do this??.
//echo -a $base(77F5........)
which will returns me the original string? which is it test

that's all folks

#138395 30/12/05 05:50 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:
alias asc2hex {
  var %i = 1, %result
  while ($mid($1,%i,1) != $null) {
    %result = %result $+ $base($asc($v1),10,16,2)
    inc %i
  }
  return %result
}
alias hex2asc {
  var %i = 1, %result
  while ($mid($1,%i,2) != $null) {
    %result = %result $+ $chr($replace($base($v1,16,10),32,10))
    inc %i 2
  }
  return $replace(%result,$lf,$chr(32))
}


$asc2hex(hello world) -> 68656C6C6F20776F726C64
$hex2asc(68656C6C6F20776F726C64) -> hello world

#138396 30/12/05 06:24 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
As a more general reply than hixxy's:

To change a number used with $base() back into it's original form simply switch the 2nd and 3rd parameters round.
eg.
$base(74,10,16) -> 4A
$base(4A,16,10) -> 74.

This won't work with your example though because you're giving $base() some invalid input. $base() is for changing the base used to represent a number, it's not some kind of encoding method. Since the letters t, e, and s are not present in the input base you're using (10), $base() is giving out some random figure in the output base (16) that won't have any relevance to the original text inputted.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#138397 31/12/05 12:12 PM
Joined: Jul 2005
Posts: 56
W
whoami Offline OP
Babel fish
OP Offline
Babel fish
W
Joined: Jul 2005
Posts: 56
special thanks ppl blush


Link Copied to Clipboard