Hello, I need some help with my Mime encryption decoder. Can someone please tell me what is wrong with it, that it doesn't decodes right. Thanks.

P.S: the main function of the decryption is: de_mime().

Again, thanks for the help.

Code:
void byte_binary(byte x, FILE *fp, int till)
 {
  int i;

  for (i=BYTE_LNT-1; i>=till; --i)
   fprintf(fp, "%d ", binary_split(x, i));
 }
int binary_split(byte x, int i)
 {
  x >>= i;
  x &= 0x01;
  return(x);
 }
int binary_byte(int b[])
 {
  int factor, i, zzz=0;

  factor = 1;
  for(i=BYTE_LNT-1; i>=0; i--)
   {
    if(b[i] == 1)
     zzz += factor;
    factor += factor;
   }
  return(zzz);
 }

void de_mime(char text_in[])
 {
  FILE *fp;
  char text[MAX_LNT]={0}, string[MAX_LNT]={0};
  int i, j, stop, k, b1[BYTE_LNT]={0,0,0,0,0,0,0,0};
  char CypherTable[64] = {
    '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','+','/'};  

  strcpy(text, text_in);
  for (i=strlen(text)-2; i<strlen(text); i++)
   if (text[i]=='=') text[i] = 0;

  fp = fopen(file1, "w");
  for (k=0; k<strlen(text); k++)
   {
    if ((text[k]>=65)&&(text[k]<=90)) {
     i = 0; j = 25;
    } else if ((text[k]>=97)&&(text[k]<=122)) {
       i = 26; j = 51;
      } else if ((text[k]>=48)&&(text[k]<=57)) {
         i = 52; j = 61;
        } else {
           i = 62; j = 63;
          }
    stop = 0;
    while ((j>=i)&&(!stop))
     if (text[k]==CypherTable[j])
      stop++;
     else j--;

    byte_binary(j, fp, 2);

   }
  fclose(fp);
  fp = fopen(file1, "r");
  for (k=0; k<((strlen(text)*BYTE_LNT-(strlen(text))*2))/BYTE_LNT; k++) {
   for (i=0; i<BYTE_LNT; i++)
    fscanf(fp, "%d", &b1[i]);
   string[k] = binary_byte(b1);
  }
  fclose(fp);
  unlink(file1);
  printf("%s", string);
 }