rockcavera commented on a Page, mIRC $base64()  -  Feb 14, 2017

Hi, Arigateaux.

Your code is not 100% correct as it allows bits not to be converted when the input bytes length is not divisible by 3.

If you want to use base64 without the special character "=", use: $remove($encode(text,m),=)

raccoon  -  Feb 15, 2017

It's worth noting that $encode() is a left-to-right operation, while $base() is a right-to-left operation.

rockcavera  -  Feb 16, 2017

Yes, you have it too.

So, use either of these two aliases:

alias base64 return $regsubex($encode($1,m),/(.)(==?)/,$gettok(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 + /,$calc((($findtokcs(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 + /,\1,1,32) - 1) // (2 ^ (2 ^ $len(\2)))) + 1),32))

alias base64 return $regsubex(b64,$regsubex(b2,$1,/(.)/g,$base($asc(\t),10,2,8)),/([01]{1 $+ $chr(44) $+ 6})/g,$gettok(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 + /,$calc($base(\t,2,10) + 1),32))

The first continues using $encode and the "//" limits to versions equal or superior 7.41.

rebel9  -  Feb 23, 2018

Or you can just use one line.

alias base64 { $iif($isid,return,editbox -a) $right($left($unsafe($1-),-6),-8) }

Enjoy!!!

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.