This snippet is a Hexadecimal encoder and decoder. Just add $hex(your text here).encode/decode
IE:
alias test {
if ($1 == encode) { echo -a $hex($2-).encode }
else { echo -a $hex($2-).decode }
}
NOTE: I was having computer difficulties when working on this code, so sorry if there's any bugs or script errors, and please notify me of them.
alias hex {
if ($1) {
if ($prop == encode) {
return $replacecs($1-,$chr(44),2C,$chr(40),28,$chr(41),29,$chr(36),24,$chr(37),25,$chr(125),7D,$chr(123),7B,$chr(32),20,!,21,",22,#,23,&,26,',27,*,2A,+,2B,-,2D,.,2E,/,2F,0,30,1,31,2,32,3,33,4,34,5,35,6,36,7,37,8,38,9,39,:,3A,;,3B,<,3C,=,3D,>,3E,?,3F,`,60,a,61,b,62,c,63,d,64,e,65,f,66,g,67,h,68,i,69,j,6A,k,6B,l,6C,m,6D,n,6E,o,6F,p,70,q,71,r,72,s,73,t,74,u,75,v,76,w,77,x,78,y,79,z,7A,$chr(124),7C,~,7E) $+ 00
}
if ($prop == decode) {
var %dec = $calc($len($1-) / 2)
var %dec. = $len($1-)
var %num = 2
while (%num =< %dec) {
set %txt $left($1-,%num) $+ $chr(1) $+ $right($1-,$calc(%dec. - %num))
inc %num 2
}
%num = 1
while (%num <= $numtok(%txt,1)) {
set %txt $replace($gettok(%txt,%num,32),2C,$chr(44),28,$chr(40),29,$chr(41),24,$chr(36),25,$chr(37),7D$chr(125),7B,$chr(123),20,$chr(32),21,!,22,",23,#,26,&,27,',2A,*,2B,+,2D,-,2E,.,2F,/,30,0,31,1,32,2,33,3,34,4,35,5,36,6,37,7,38,8,39,9,3A,:,3B,;,3C,<,3D,=,3E,>,3F,?,60,`,61,a,62,b,63,c,64,d,65e,66,f,67,g,68,h,69,i,6A,j,6B,k,6C,l,6D,m,6E,n,6F,o,70,p,71,q,72,r,73,s,74,t,75,u,76,v,77,w,78,x,79,y,7A,z,7C,$chr(124),7E,~)
inc %num 1
}
set %txt $remove(%txt, $chr(1))
return %txt
unset %txt
}
}
}