SourceFormatX

Overview

Features

Why Use It

Formatting Show

Integration

Screenshots

Documentation

FAQs & Tips

Update History

Award Gallery

Testimonials

License Policy

CodeMorph

CodeToHtml

C/C++ Source Code Obfuscation Show


SourceFormatX is not only the multi-language code formatter but also a code obfuscator that can obfuscate your C and C++ source code for the purposes of source code security and intellectual property protection.

C/C++ Java C# Delphi (Pascal)
PHP JSP JavaScript HTML Components
CORBA IDL


  C/C++ Source Code Obfuscation Examples:     Example 1   |   Example 2   |   Example 3

This is C code obfuscating sample, it's the base64 encoding source code of BSD system. The purpose of it is to show the power of SourceFormatX C/C++ Code Formatter's syntax parse engine.

  /* Before C++ Code Obfuscating */

  #include <sys/types.h>
  #include <sys/param.h>
  #include <sys/socket.h>
  #include <netinet/in.h>
  #include <arpa/inet.h>

  #include <ctype.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>

  #include "gpsd_config.h"
  #include "bsd-base64.h"

  #define Assert(Cond) if (!(Cond)) abort()

  static const char Base64[] =
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  static const char Pad64 = '=';

  int b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize)
  {
    size_t datalength = 0;
    u_char input[3];
    u_char output[4];
    size_t i;

    while (2 < srclength)
    {
      input[0] = *src++;
      input[1] = *src++;
      input[2] = *src++;
      srclength -= 3;

      output[0] = input[0] >> 2;
      output[1] = ((input[0] &0x03) << 4) + (input[1] >> 4);
      output[2] = ((input[1] &0x0f) << 2) + (input[2] >> 6);
      output[3] = input[2] &0x3f;
      Assert(output[0] < 64);
      Assert(output[1] < 64);
      Assert(output[2] < 64);
      Assert(output[3] < 64);

      if (datalength + 4 > targsize)
        return (-1);
      target[datalength++] = Base64[output[0]];
      target[datalength++] = Base64[output[1]];
      target[datalength++] = Base64[output[2]];
      target[datalength++] = Base64[output[3]];
    }

    if (0 != srclength)
    {
      input[0] = input[1] = input[2] = '\0';
      for (i = 0; i < srclength; i++)
        input[i] = *src++;

      output[0] = input[0] >> 2;
      output[1] = ((input[0] &0x03) << 4) + (input[1] >> 4);
      output[2] = ((input[1] &0x0f) << 2) + (input[2] >> 6);
      Assert(output[0] < 64);
      Assert(output[1] < 64);
      Assert(output[2] < 64);

      if (datalength + 4 > targsize)
        return (-1);
      target[datalength++] = Base64[output[0]];
      target[datalength++] = Base64[output[1]];
      if (srclength == 1)
        target[datalength++] = Pad64;
      else
        target[datalength++] = Base64[output[2]];
      target[datalength++] = Pad64;
    }
    if (datalength >= targsize)
      return (-1);
    target[datalength] = '\0';
    return (datalength);
  }

  int b64_pton(char const *src, u_char *target, size_t targsize)
  {
    size_t tarindex;
    int state, ch;
    char *pos;

    state = 0;
    tarindex = 0;

    while ((ch = *src++) != '\0')
    {
      if (isspace(ch))
        continue;

      if (ch == Pad64)
        break;

      if ((pos = strchr(Base64, ch)) == NULL)
        return (-1);

      switch (state)
      {
        case 0:
          if (target)
          {
            if (tarindex >= targsize)
              return (-1);
            target[tarindex] = (pos - Base64) << 2;
          }
          state = 1;
          break;
        case 1:
          if (target)
          {
            if (tarindex + 1 >= targsize)
              return (-1);
            target[tarindex] |= (pos - Base64) >> 4;
            target[tarindex + 1] = ( (pos - Base64) &0x0f) << 4;
          }
          tarindex++;
          state = 2;
          break;
        case 2:
          if (target)
          {
            if (tarindex + 1 >= targsize)
              return (-1);
            target[tarindex] |= (pos - Base64) >> 2;
            target[tarindex + 1] = ( (pos - Base64) &0x03) << 6;
          }
          tarindex++;
          state = 3;
          break;
        case 3:
          if (target)
          {
            if (tarindex >= targsize)
              return (-1);
            target[tarindex] |= (pos - Base64);
          }
          tarindex++;
          state = 0;
          break;
      }
    }

    if (ch == Pad64)
    {
      ch =  *src++;
      switch (state)
      {
        case 0:
        case 1:
          return (-1);
        case 2:
          for (; ch != '\0'; ch =  *src++)
            if (!isspace(ch) )
              break;
          if (ch != Pad64)
            return (-1);
          ch = *src++;
        case 3:
          for (; ch != '\0'; ch =  *src++)
            if (!isspace(ch) )
              return (-1);
          if (target != 0 && target[tarindex] != 0)
            return (-1);
      }
    }
    else
    {
      if (state != 0)
        return (-1);
    }

    return (tarindex);
  }


  /* After C++ Code Obfuscating */

  #include <sys/types.h>
  #include <sys/param.h>
  #include <sys/socket.h>
  #include <netinet/in.h>
  #include <arpa/inet.h>
  #include <ctype.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  #include "gpsd_config.h"
  #include "bsd-base64.h"
  #define Assert(Cond) if (!(Cond)) abort()
  static const char Base64[]=
  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";static
  const char Pad64='=';int b64_ntop(u_char const*src,size_t srclength,char*target
  ,size_t targsize){size_t datalength=0;u_char input[3];u_char output[4];size_t i
  ;while(2<srclength){input[0]=*src++;input[1]=*src++;input[2]=*src++;srclength-=
  3;output[0]=input[0]>>2;output[1]=((input[0]&0x03)<<4)+(input[1]>>4);output[2]=
  ((input[1]&0x0f)<<2)+(input[2]>>6);output[3]=input[2]&0x3f;Assert(output[0]<64)
  ;Assert(output[1]<64);Assert(output[2]<64);Assert(output[3]<64);if(datalength+4
  >targsize)return(-1);target[datalength++]=Base64[output[0]];target[datalength++
  ]=Base64[output[1]];target[datalength++]=Base64[output[2]];target[datalength++]
  =Base64[output[3]];}if(0!=srclength){input[0]=input[1]=input[2]='\0';for(i=0;i<
  srclength;i++)input[i]=*src++;output[0]=input[0]>>2;output[1]=((input[0]&0x03)
  <<4)+(input[1]>>4);output[2]=((input[1]&0x0f)<<2)+(input[2]>>6);Assert(output[0
  ]<64);Assert(output[1]<64);Assert(output[2]<64);if(datalength+4>targsize)return
  (-1);target[datalength++]=Base64[output[0]];target[datalength++]=Base64[output[
  1]];if(srclength==1)target[datalength++]=Pad64;else target[datalength++]=Base64
  [output[2]];target[datalength++]=Pad64;}if(datalength>=targsize)return(-1);
  target[datalength]='\0';return(datalength);}int b64_pton(char const*src,u_char*
  target,size_t targsize){size_t tarindex;int state,ch;char*pos;state=0;tarindex=
  0;while((ch=*src++)!='\0'){if(isspace(ch))continue;if(ch==Pad64)break;if((pos=
  strchr(Base64,ch))==NULL)return(-1);switch(state){case 0:if(target){if(tarindex
  >=targsize)return(-1);target[tarindex]=(pos-Base64)<<2;}state=1;break;case 1:if
  (target){if(tarindex+1>=targsize)return(-1);target[tarindex]|=(pos-Base64)>>4;
  target[tarindex+1]=((pos-Base64)&0x0f)<<4;}tarindex++;state=2;break;case 2:if(
  target){if(tarindex+1>=targsize)return(-1);target[tarindex]|=(pos-Base64)>>2;
  target[tarindex+1]=((pos-Base64)&0x03)<<6;}tarindex++;state=3;break;case 3:if(
  target){if(tarindex>=targsize)return(-1);target[tarindex]|=(pos-Base64);}
  tarindex++;state=0;break;}}if(ch==Pad64){ch=*src++;switch(state){case 0:case 1:
  return(-1);case 2:for(;ch!='\0';ch=*src++)if(!isspace(ch))break;if(ch!=Pad64)
  return(-1);ch=*src++;case 3:for(;ch!='\0';ch=*src++)if(!isspace(ch))return(-1);
  if(target!=0&&target[tarindex]!=0)return(-1);}}else{if(state!=0)return(-1);}
  return(tarindex);}

Example 1   |   Example 2   |   Example 3

  Download SourceFormatX C/C++ Code Formatter to format and obfuscate your C and C++ source code files today!