C++ - Binary Converter

  • 0 Replies
  • 78 Views

0 Members and 1 Guest are viewing this topic.

Offline Omega

    *
  • The Boss (Admin)
  • Black Hat Sec Member
  • Telegram: @BLACKHATSEC_FORUM
  • Posts: 190
  • Popularity: +1/-0
  • God of Malware
    • View Profile
    • Awards
« on: March 14, 2022, 09:59:03 AM »
C++ - Binary Converter

Code
Converts Text Into Binary. (Using The Division Method Through ASCII Code).

=======================================================

#include <iostream>
#include <cstring>
#include <cstdlib>

using namespace std;

//Varaible Declaration
char *Entry, Letter, Choice[2];
int Ascii, len, Binary[8], Total;
void Convert();

int main()
{
      Convert();   
      return 0;
}       
       
void Convert()
{
   Entry = new char[501];
   cout << "Enter Text To Convert(Up To 500 Chars): ";
   cin.getline(Entry, 500);
   len = strlen(Entry);

   for(int i = 0; i < len; i++)
   {
      Total = 0;
      Letter = Entry[i];
      Ascii = Letter; 
      while(Ascii > 0)
      {
         if((Ascii%2)==0)
         {
            Binary[Total] = 0;
            Ascii = Ascii/2;
            Total++;
         }
         else
         {
            Binary[Total] = 1;
            Ascii = Ascii/2;
            Total++;
         }
      }
      Total--;

      while(Total >= 0)
      {
         cout << Binary[Total];
         Total--;
      }
   }
   delete[] Entry; //Freeup Memory
   return 0;
}
  • Discord: BLACK HAT SEC#5222
  • [+]
  • [-]

  •