Announcement

Collapse
No announcement yet.

Text to Binary Converter?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Text to Binary Converter?

    Anyone know of a (downloadable) PHP script that can convert text to binary and vice versa using a simple form?

    kinda like the one here: http://snarkles.net/binary.php

    Thanks!
    OPEN TECH SUPPORT
    "Tech is our middle name!"

  • #2
    Make one yourself.... get an ASCII chart, and use a str_replace statements like he did.

    That's pretty kuel though!

    Comment


    • #3
      I got board....
      PHP Code:
      <?
      // php configuration
          // turn off runtime magic quotes
          
      set_magic_quotes_runtime(0);
          
      // turn on GPC magic quotes
          
      ini_set("magic_quotes_gpc","1");
          
      // set the error reporting level
          
      error_reporting(2039);

      echo<<<myHTML
      <html
      <body>
      myHTML;

      if (
      $text) {
          echo 
      "<pre>";
          
      $i=0;
          while (
      $i strlen($text)) {
              
      $tmp_string[$i] = $text[$i];
              
      $i++;
          }
          echo 
      "<b>String:</b>\n";
          echo 
      $text;
          echo 
      "\n\n";

          echo 
      "<b>ASCII:</b>\n";
          foreach (
      $tmp_string as $letter) {
              echo 
      ord($letter) . " ";
          }

          echo 
      "\n\n";

          echo 
      "<b>Binary:</b>\n";
          foreach (
      $tmp_string as $letter) {
              
      $tmp ord($letter);
              for (
      $i=7$i>=0$i--) {
                  
      $bit pow(2,$i);
          
      //        echo $i . "\t" . $bit . "\t";
                  
      if ($tmp >= $bit) {
                      echo 
      "1";
                      
      $tmp -= $bit;
                  }
                  else {
                      echo 
      "0";
                  }
          
      //        echo "\t$tmp\n";
              
      }
              echo 
      " ";
          }
          echo 
      "</pre>";
      }
      else {
          
      //make something to request $text
      }
      echo<<<myHTML
      </body>
      </html>
      myHTML;
      ?>
      Maybe later, I'll finish it. But right now, you can pass $text via GET and see what it does. Hack it to your needs.

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...
      X