I was bored so I made another small snippet.
It uses this de- and encoding: http://en.wikipedia.org/wiki/Transposition_cipher#Columnar_transposition
You have to give a keyword, and then what to en- or decode; example:
$Encodex(Dani,This is my encoded text) will return cdt^_s¶O¬hi`¶n¬
_o¶dn¬j¬o
Now that doesn't make any sense, does it?
But $decodex(Dani,cdt^_s¶O¬hi`¶n¬
_o¶dn¬j¬o) returns "This is my encoded text" again, hooray, it works!
Besides the columnar transposition (as explained on wiki), it also 'encodes' the outcome of that encryption by moving the CHR codes of every character by an (unpredictable) number, based on the MD5 of the keyword. This explains the weird blocks.
It is way more secure than the mIRC built in $decode/$encode and it also is really hard to crack for people if they don't have the correct keyword.
Just being one letter of with the keyword in the $decodex alias returns some stuff nobody understand, example: $decodex(Daniel,cdt^_s¶O¬hi¶n¬`_o¶dn¬j¬o) -> Sgh hrlx mbndc dws $decodex(Wani,cdt^_s¶O¬hi
¶n¬`_o¶dn¬j¬o) -> kjuVuk {goqefp fvgvzg
Now that doesn't make any sense, while its just one or two characters off from the real key!
Also, it's using those ¶ and ¬ because mIRC automatically filters double spaces, which causes problems with this script, so instead i'm replacing those spaces with those weird characters and afterwards replacing those spaces back.
(Above all hocus pocus for you? Doesn't matter! You will learn eventually)
Go ahead and have some fun with it, comment if you have any questions or something else. Try it out ;-)
Usage once more:
$Encodex(Key,Text) -> returns encoded string
$decodex(Key,Encoded string) -> returns text
/encodex Key,Text -> echo's encoded string
/decodex Key,Encoded string -> echo's text
Only restrictions are that you cannot use comma's in the key, and the key is incasesensitive. Also trying to encode some weird symbols (E.G. µ, ¶ and ¬) CAN cause problems.
alias encodex {
if (!$isid) tokenize 44 $1-
var %kwoord = $lower($1)
var %encode = $replace($2,$chr(32),¬)
var %x = 1,%y = 1
while (%x <= $len(%encode)) {
if (%y > $len(%kwoord)) var %y = 1
var %c. [ $+ [ %y ] ] %c. [ $+ [ %y ] ] $+ $mid(%encode,%x,1)
inc %x
inc %y
}
var %kwoords = $regsubex($sorttok($left($regsubex(%kwoord,/(.)/g,$asc(\1) $+ - $+ \n $+ .),-1),46,n),/\d*-/g,)
var %x = 1,%msg
while (%x <= $numtok(%kwoords,46)) {
var %msg = %msg $+ $chr(32) %c. [ $+ [ $gettok(%kwoords,%x,46) ] ] $+ ¶
inc %x
}
var %msg = $left(%msg,-1)
var %nr = $left($regsubex($md5(%kwoord),/\D/g,),1)
$iif($isid,return,echo -a) $replace($regsubex(%msg,/([^¬¶])/g,$chr($calc($asc(\1) - %nr))),$chr(44),¾¿@zrL¢#)
}
alias decodex {
if (!$isid) tokenize 44 $1-
var %kwoord = $lower($1)
var %nr = $left($regsubex($md5(%kwoord),/\D/g,),1)
var %decode $regsubex($replace($2-,¾¿@zrL¢#,$chr(44)),/([^¬¶])/g,$chr($calc($asc(\1) + %nr)))
var %kwoords = $regsubex($sorttok($left($regsubex(%kwoord,/(.)/g,$asc(\1) $+ - $+ \n $+ .),-1),46,n),/\d*-/g,)
var %x = 1
while (%x <= $numtok(%decode,182)) {
var %c. [ $+ [ $gettok(%kwoords,%x,46) ] ] $gettok(%decode,%x,182)
inc %x
}
var %x = 1
while (%x <= $len($remove(%decode,$chr(32)))) {
var %y = 1
while (%y <= $numtok(%decode,182)) {
var %msg = %msg $+ $mid(%c. [ $+ [ %y ] ],%x,1)
inc %y
}
inc %x
}
$iif($isid,return,echo -a) $replace(%msg,¬,$chr(32))
}