It couldn't be easier to do Triple-DES encryption on the palm. I may have
some typing errors but something like the following should work.

#include <Encrypt.h>

Err DoTripleDES(Boolean encrypt, MemPtr inputP, MemPtr EncKey1P, MemPtr
EncKey2P, MemPtr resultP)
{
Err error=0;
Int16 inputLen, i;

// note: can't do a zero length string
inputLen = StrLen(EncStringP);
if(inputLen==0) goto EndFunc;

// make the length of the intput/output string to be a factor of 8 for
encrypting
// note: it will already be a factor of 8 for decrypting.
if(inputLen % 8)
    inputLen += 8 - (inputLen % 8);
MemPtrResize(resultP, inputLen);
MemSet(resultP, inputLen, 0);

for(i=0; i<inputLen; i+=8) {
    UInt8 buffer[9];

    MemSet(buffer, 9, 0);
    MemMove(buffer, (unsigned char*)inputP + i, 8);

    // do triple DES
    if(encrypt){
        EncDES(buffer, EncKey1P, buffer, true);
        EncDES(buffer, EncKey2P, buffer, false);
        EncDES(buffer, EncKey1P, buffer, true);
    }
    else{
        EncDES(buffer, EncKey1P, buffer, false);
        EncDES(buffer, EncKey2P, buffer, true);
        EncDES(buffer, EncKey1P, buffer, false);
    }
    StrCat(resultP, (const char*)buffer);
}

EndFunc:
return(error);
}


"robert20155" <[EMAIL PROTECTED]> wrote in message
news:88653@palm-dev-forum...
>
> There's a header Encrypt.h showing function calls for MD4 and MD5 hashing,
> as well as DES encryption.  Encrypt.h's comments block says it was added
as
> part of Palm OS 4; don't know if it was available as an undocumented
> function call in earlier Palm OS versions or not.  You can do Triple-DES
> encryption using the DES function.   See Bruce Schneier's "Applied
> Cryptography" book, or equivalent, for details.
> --Rob
>
>
> "Dave Brown" <[EMAIL PROTECTED]> wrote in message
> news:88569@palm-dev-forum...
> >
> > Hi-
> >
> > I've looked through the archives and searched around w/o much success
for
> > encryption libraies.
> >
> > I'm writing an application that needs to accept credit cards and thus
need
> > to store the CC information. Needless to say I don't want to store this
in
> > clear-text.
> >
> > Does anyone know of some encryption libraries available to handle this.
> >
> > Thanks,
> > Dave
> >
> >
> >
>
>
>
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to