mIRC $base64()

By Arigateaux on Feb 14, 2017

Returns a value in Base-64, since mIRC $base() only goes up to 36.

alias base64 {
  var %indexTable = ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
  var %input = $regsubex($$1, /(.)/g, $base($asc(\t), 10, 2, 8))
  var %n = $regex(%input, /(\d{6})/g)
  var %i = 1
  while (%i <= %n) {
    var %translate = %translate $+ $mid(%indexTable, $calc($base($regml(%i), 2, 10) + 1), 1)
    inc %i
  }
  return %translate
}

Comments

Sign in to comment.
ircdeLi   -  Feb 19, 2017

Hello friends. We are working on the development of mirc coding and irc servers as the biggest of the Turkish irc servers, www.turkirc.com and www.Sohbet.Net. We hope that you will reach out to the world's most valuable mirc coders and share their code on the Turkish platforms and review our codes to help each other and help us live mIRC. Today, almost every feature is encoded and we are looking for new ideas. We are very pleased if you can contact us for this reason.
Contact: www.turkirc.com & www.Sohbet.Net
Mail: help@sohbet.Net
Channel #Operhelp
Nick: OxiGen & deLi

 Respond  
rockcavera   -  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.

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.