UUEncoding is pretty trivial. Here is a routine to UUEncode and a
routine to calculate the destination size so you can allocate a buffer.
-jjf
// A little helper macro
#define ENCODE(m) ((m) ? (m) + 32 : 0x60)
static void UUEncode( Char *fname, // The filename we are using
Byte *data, // Binary data to encode
UInt datasize, // Size of the binary data
Char *outbuf ) // OUT: Encoded ASCII data
{
// Generate the UUencode header
StrPrintF(outbuf, "\nbegin 600 %s\n", fname);
while (*outbuf)
outbuf++;
// Full lines first
while (datasize >= 45)
{
UInt n;
// Line header (actual data length (45) + 32)
*(outbuf++) = 'M';
// 15 sets of 3 bytes
for (n = 0 ; n< 15 ; n++)
{
ULong l;
// 3 in...
l = *(data++);
l <<= 8;
l |= *(data++);
l <<= 8;
l |= *(data++);
datasize -= 3;
// 4 out...
*(outbuf++) = ENCODE((l >> 18) & 0x3F);
*(outbuf++) = ENCODE((l >> 12) & 0x3F);
*(outbuf++) = ENCODE((l >> 6) & 0x3F);
*(outbuf++) = ENCODE(l & 0x3F);
}
// New line
*(outbuf++) = '\n';
}
// Last line (if needed)
if (datasize)
{
// Line header (actual data length + 32)
*(outbuf++) = (Byte)(datasize + 32);
while (datasize)
{
ULong l;
// 3 in... (maybe)
l = *(data++);
datasize--;
l <<= 8;
if (datasize)
{
l |= *(data++);
datasize--;
}
l <<= 8;
if (datasize)
{
l |= *(data++);
datasize--;
}
// 4 out... (always)
*(outbuf++) = ENCODE((l >> 18) & 0x3F);
*(outbuf++) = ENCODE((l >> 12) & 0x3F);
*(outbuf++) = ENCODE((l >> 6) & 0x3F);
*(outbuf++) = ENCODE(l & 0x3F);
}
// Newline
*(outbuf++) = '\n';
}
// End marker
StrPrintF(outbuf, "end\n");
}
static UInt GetUUEncodeSize( Char *fname, // The filename we are
using
UInt datasize ) // The size of the
binary data to encode
{
UInt esize;
// Start with fixed header and footer size
esize = 16;
// Add the filename
esize += StrLen(fname);
// Add full lines.
// 45 / 3 = 15 * 4 = 60 + length byte + newline = 62
esize += (datasize / 45) * 62;
// Any data left?
// Just add a full line worth... (so sue me)
if (datasize % 45)
esize += 62;
return esize;
}
-----Original Message-----
From: Russell Y. Webb [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 16, 2000 9:46 AM
To: Palm Developer Forum
Subject: Re: Des Encryption
How about the DES routines in the ROM? Look at Encrypt.h
Russ
>hi,
>
>Anyone know of a port of Des encryption to the palm?
>How about about functions to uuencode?
>
>thanks for any direction you can give.
>
>Matt Laube
>Bachmann Software
>
>
>--
>For information on using the Palm Developer Forums, or to unsubscribe,
please
>see http://www.palm.com/devzone/mailinglists.html
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html