alias perl_decode {
var %text = $1-
var %key = secretkey
var %response
var %i, %j, %num ,%result
var %text_len = $len(%text)
var %key_len = $len(%key)
%i = $calc(%text_len -1)
while (%i >= 0) {
var %chop = $right(%text,1)
%text = $left(%text,-1)
var %num = $asc(%chop)
if (%num == 127) { %num = 58 }
%num = $calc(%num - 33)
%j = %i
while (%j < %key_len) {
%num = $calc(%num - ($asc($mid(%key,$calc(%j +1),1)) + %key_len))
inc %j %text_len
}
%num = $calc($perl_modulus(%num,95) + 33)
.echo -a %num
%result = %result $+ $chr(%num)
dec %i
}
return %result
}
;Perl has a very odd way of handling modulus
alias -l perl_modulus {
if ($1 < 0) {
var %i = 1
while ($calc(%i * $2) <= $abs($1)) {
inc %i
}
var %m = $calc(%i * $2)
return $calc(%m - $abs($1))
}
return $calc($1 % $2)
}