Binary text converter

By sunslayer on Jun 14, 2010

i hadn't played with mIRC in a while and i figured this would be fun

this converts text to binary/binary to text
uses:

$binary(hello) = 0110100001100101011011000110110001101111
$binary(0110100001100101011011000110110001101111) = hello
alias binary {
  if ($regex($$1-,/^([01]{8})+$/)) {
    .noop $regex(bin,$1-,/([01]{8})/g)
    var %a = 1,%b = 128 64 32 16 8 4 2 1,%bin
    while ($regml(bin,%a) != $null) { var %bin = $+(%bin,$iif($chr($calc($regsubex($v1,/(\d)/g,$+($calc($gettok(%b,\n,32) * \t),+)))) == $chr(32),$v1),$v1) | inc %a }
  }
  else {
    var %chr = $regsubex($$1-,/(.)/g,$+($asc(\t),$chr(32))),%a = $numtok(%chr,32),%bin
    while (%a) {
      var %b = $gettok(%chr,%a,32),%c = 1,%d,%e
      while (%c <= 8) { var %d = $floor($calc(%b /2)),%e = $+($calc(%b % 2),%e),%b = %d | inc %c }
      %bin = $+(%e,%bin)
      dec %a
    }
  }
  $iif($isid,return,echo -a) %bin
}

Comments

Sign in to comment.
Gummo   -  Jul 01, 2010

It was definitely spam, she/it attempted to force the "follow" option on a URL in a post, which is often set to "nofollow" to prevent successful spam on forums with regard to improving search engine results.

 Respond  
Jethro   -  Jun 30, 2010

Right...aside from her drivel, I like the adjective vocabulary unanimous. lol

 Respond  
sunslayer   -  Jun 30, 2010

sunslayer, are you sure kathy is not a spam? 'cause she sure sounds like one to me...
She also posted in another thread with a sentence that looks as if it was translated with an online translator. She seems to be posting "incoherently and inconsistently."

And if she was really a spam, you sure were gullible and naive to respond to her. lol i didn't really understand anything she said but i took it as a compliment lol

 Respond  
Jonesy44   -  Jun 30, 2010

i don't even understand the sentence.

 Respond  
Jethro   -  Jun 30, 2010

sunslayer, are you sure kathy is not a spam? 'cause she sure sounds like one to me...
She also posted in another thread with a sentence that looks as if it was translated with an online translator. She seems to be posting "incoherently and inconsistently."

And if she was really a spam, you sure were gullible and naive to respond to her. lol

 Respond  
sunslayer   -  Jun 30, 2010

thanks kathy :)

 Respond  
sunslayer   -  Jun 25, 2010

sunslayer, you missed the #:msg #lol
@naruto7
ask in the mIRC snippet requests forum

 Respond  
naruto7   -  Jun 25, 2010

its not working for me can u past your script there might be something i missed

 Respond  
Jethro   -  Jun 25, 2010

It's working for me.

I entered: !binary hello naruto7
Returns:

01101000011001010110110001101100011011110010000001101110011000010111001001110101011101000110111100110111

Conversely,

!binary 01101000011001010110110001101100011011110010000001101110011000010111001001110101011101000110111100110111

Returns hello naruto7

 Respond  
naruto7   -  Jun 25, 2010

its still not working just give me the full script with the part u edited
mine is set like this

on $*:text:$(/^!binary ( $+ $2- $+ )/iS):*:{
  msg $iif(#,#,$nick) $binary($2-)
}
alias binary {
  if ($regex($$1-,/^([01]{8})+$/)) {
    .noop $regex(bin,$1-,/([01]{8})/g)
    var %a = 1,%b = 128 64 32 16 8 4 2 1,%bin
    while ($regml(bin,%a) != $null) { var %bin = $+(%bin,$iif($chr($calc($regsubex($v1,/(\d)/g,$+($calc($gettok(%b,\n,32) * \t),+)))) == $chr(32),$v1),$v1) | inc %a }
  }
  else {
    var %chr = $regsubex($$1-,/(.)/g,$+($asc(\t),$chr(32))),%a = $numtok(%chr,32),%bin
    while (%a) {
      var %b = $gettok(%chr,%a,32),%c = 1,%d,%e
      while (%c <= 8) { var %d = $floor($calc(%b /2)),%e = $+($calc(%b % 2),%e),%b = %d | inc %c }
      %bin = $+(%e,%bin)
      dec %a
    }
  }
  $iif($isid,return,echo -a) %bin
}
 Respond  
Jethro   -  Jun 25, 2010

naruto7, try this:

on $*:text:$(/^!binary ( $+ $2- $+ )/iS):*:{
  msg $iif(#,#,$nick) $binary($2-)
}

Usage: !binary MessageHere

Sunslayer's won't work because he missed the #: on accident.

 Respond  
naruto7   -  Jun 25, 2010

umm its not working

 Respond  
Jethro   -  Jun 25, 2010

sunslayer, you missed the #:msg #

But this will work for both channel and pm:

on *:text:!binary *:*:msg $iif(#,#,$nick) $binary($2-)
 Respond  
sunslayer   -  Jun 25, 2010
on *:text:!binary *:msg # $binary($2-)
 Respond  
naruto7   -  Jun 25, 2010

ok now it works but can u get it to where it will work when other people use the command since it is on my bot

 Respond  
napa182   -  Jun 25, 2010

naruto7 type

//echo -a $binary(hello)

or

/binary hello
 Respond  
naruto7   -  Jun 25, 2010

i don't seem to be able to get it to work :/ i typed $binary(hello) and i also checked the coding and i don't see an activation code to start the script

 Respond  
sunslayer   -  Jun 18, 2010

what you mean VinX?

 Respond  
VinX   -  Jun 18, 2010

hehe

 Respond  
Sorasyn   -  Jun 18, 2010

Lol ^

 Respond  
VinX   -  Jun 18, 2010

could u make it for a bot pl0x ?

 Respond  
sunslayer   -  Jun 16, 2010

unsuccessful troll is unsuccessful

 Respond  
Jethro   -  Jun 16, 2010

Did someone named lucy sign up just to troll you thread, sunslayer? Just kidding...lol

 Respond  
sunslayer   -  Jun 16, 2010

@ChiefDean binary consists of only 1's and 0's, no spaces
u can change line 12 to

%bin = $+(%e,$chr(32),%bin)

which will give u spaces but will also break the decoder portion

 Respond  
Jonesy44   -  Jun 16, 2010

Ah yeah nice one sunslayer, didn't know the last param was leading no's. Yeah then you could chop it into 8's and you're sorted as far as converting back's concerned:)

 Respond  
ChiefDean   -  Jun 16, 2010

Can you make it put a space after every 8th character? Its easier to read that way...

Over all very nice snippet. Will be useful for... IDK. You'd be surprised!

 Respond  
sunslayer   -  Jun 16, 2010

@jonesy44

$base(100,10,2,8)

will return 01100100 instead of 1100100

 Respond  
Jonesy44   -  Jun 16, 2010
alias bconv echo -a $regsubex($$1-,/(.)/gSi,$base($asc(\t),10,2))

Yeah you can use regsubex for literal binary but converting it back is harder because it's not fixed point.

 Respond  
sunslayer   -  Jun 16, 2010

thanks peepz :)

edit: fixed the 00000000 bug

 Respond  
Jethro   -  Jun 16, 2010

This is actually good to be used as that of Morse code alternative. :-) Nice thinking and well done. lol

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