Go Back   Velocity Reviews > Newsgroups > Computer Security
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Computer Security - How about a Free UUENCODE in C++?

 
Thread Tools Search this Thread
Old 07-21-2004, 12:42 AM   #1
Default How about a Free UUENCODE in C++?


DECODING IS EASY

similar to this..


// UUENCODE - a Win32 utility to uuencode single files.

// Copyright (C) 1998 Clem Dye

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


#include <stdio.h>
#include <string.h>
#define ENC(c) ((c) ? ((c) & 077) + ' ': '`')

static void uuencode (FILE *f,char *nom)
{
int ch, n,idx,count;
register char *p;
char buf[80],outbuf[250];
FILE *in;

in = fopen(nom,"rb");
if (in == NULL) return;
p = strrchr(nom,'\\');
if (p) p++;
else p = nom;
fprintf(f,"\r\nbegin 0666 %s\r\n",p);
while ((n = fread (buf, 1, 45, in)) != 0)
{
idx = 0;
ch = ENC (n);
outbuf[idx++] = ch;
for (p = buf; n > 0; n -= 3, p += 3)
{
ch = *p >> 2;
ch = ENC (ch);
outbuf[idx++] = ch;
ch = ((*p << 4) & 060) | ((p[1] >> 4) & 017);
ch = ENC (ch);
outbuf[idx++] = ch;

ch = ((p[1] << 2) & 074) | ((p[2] >> 6) & 03);
ch = ENC (ch);
outbuf[idx++] = ch;

ch = p[2] & 077;
ch = ENC (ch);
outbuf[idx++] = ch;
}
outbuf[idx++] = '\r';
outbuf[idx++] = '\n';
outbuf[idx] = 0;
count = fwrite(outbuf, 1,idx,f);
if (count != idx) break;
}
fprintf(f,"%c\r\nend\r\n",ENC(0));
fclose(in);
}

int main(int argc,char *argv[])
{
FILE *f;

if (argc <= 2) {
printf("Usage %s <input file> <encoded output file>\n",argv[0]);
return(1);
}
f = fopen(argv[2],"wb");
if (f == NULL) {
printf("Impossible to open %s\n",argv[2]);
return(1);
}
uuencode(f,argv[1]);
fclose(f);
printf("Result encoded in %s\n",argv[2]);
return(0);
}


Anonieko Ramos
  Reply With Quote
Old 07-21-2004, 02:47 AM   #2
David H. Lipman
 
Posts: n/a
Default Re: How about a Free UUENCODE in C++?
This is a security News Group -- Not a C++ programming News Group.

You need to focus your posts to On Topic subject matter.

Dave



"Anonieko Ramos" <> wrote in message
news: om...
| DECODING IS EASY
|
| similar to this..
|
|
| // UUENCODE - a Win32 utility to uuencode single files.
|
| // Copyright (C) 1998 Clem Dye
|
| // This program is free software; you can redistribute it and/or
| // modify it under the terms of the GNU General Public License
| // as published by the Free Software Foundation; either version 2
| // of the License, or (at your option) any later version.
|
| // This program is distributed in the hope that it will be useful,
| // but WITHOUT ANY WARRANTY; without even the implied warranty of
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| // GNU General Public License for more details.
|
| // You should have received a copy of the GNU General Public License
| // along with this program; if not, write to the Free Software Foundation, Inc.,
| // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
| #include <stdio.h>
| #include <string.h>
| #define ENC(c) ((c) ? ((c) & 077) + ' ': '`')
|
| static void uuencode (FILE *f,char *nom)
| {
| int ch, n,idx,count;
| register char *p;
| char buf[80],outbuf[250];
| FILE *in;
|
| in = fopen(nom,"rb");
| if (in == NULL) return;
| p = strrchr(nom,'\\');
| if (p) p++;
| else p = nom;
| fprintf(f,"\r\nbegin 0666 %s\r\n",p);
| while ((n = fread (buf, 1, 45, in)) != 0)
| {
| idx = 0;
| ch = ENC (n);
| outbuf[idx++] = ch;
| for (p = buf; n > 0; n -= 3, p += 3)
| {
| ch = *p >> 2;
| ch = ENC (ch);
| outbuf[idx++] = ch;
| ch = ((*p << 4) & 060) | ((p[1] >> 4) & 017);
| ch = ENC (ch);
| outbuf[idx++] = ch;
|
| ch = ((p[1] << 2) & 074) | ((p[2] >> 6) & 03);
| ch = ENC (ch);
| outbuf[idx++] = ch;
|
| ch = p[2] & 077;
| ch = ENC (ch);
| outbuf[idx++] = ch;
| }
| outbuf[idx++] = '\r';
| outbuf[idx++] = '\n';
| outbuf[idx] = 0;
| count = fwrite(outbuf, 1,idx,f);
| if (count != idx) break;
| }
| fprintf(f,"%c\r\nend\r\n",ENC(0));
| fclose(in);
| }
|
| int main(int argc,char *argv[])
| {
| FILE *f;
|
| if (argc <= 2) {
| printf("Usage %s <input file> <encoded output file>\n",argv[0]);
| return(1);
| }
| f = fopen(argv[2],"wb");
| if (f == NULL) {
| printf("Impossible to open %s\n",argv[2]);
| return(1);
| }
| uuencode(f,argv[1]);
| fclose(f);
| printf("Result encoded in %s\n",argv[2]);
| return(0);
| }




David H. Lipman
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blockbuster Total Access means you've got FREE, three ways Jaya DVD Video 0 01-05-2007 03:54 PM
Blockbuster Online One Month FREE coupon code: 1769ta Jaya DVD Video 0 01-03-2007 04:22 PM
Finally...FREE Digital TV Again..... lcF FREE FREE FREE DVD Video 0 02-02-2006 06:22 AM
Finally...FREE Digital TV Again..... 7-[ FREE FREE FREE DVD Video 0 02-02-2006 06:13 AM
*$600 FREE At FULL-TILT POKER, Sign-Up with no C.C. to play on our free tables 24-7! bigpokerjackpotsonlyatpartypoker DVD Video 0 01-07-2006 05:00 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46