We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
If anyone needs some basic encryption in software, here's one solution. This TEA implementation fits within less than 700 bytes. It's based on original TEA. P89LPC901 needs 300ms for 32 iterations. Compiled with "OPTIMIZE (9,SIZE)".
#define _DELTA 0x9E3779B9 #define _ITER 32 /* _ITER = the number of iterations.*/ /* 32 is ample, 16 is sufficient, */ /* as few as eight should be OK. */ #define _SUM 0xC6EF3720 /********************************************************************/ /* Global variables for encryption */ /********************************************************************/ unsigned long int v0,v1; /* encrypted/decrypted data */ volatile unsigned long int code k0=0x1234aaaa, /* 128 bit key */ k1=0x5678bbbb, /* hard coded in internal */ k2=0x9abc4321, /* flash memory */ k3=0xdef0ffff; /* Same key used by host */ /********************************************************************/ /* */ /* TEA : The Tiny Encryption Algorithm (TEA) */ /* ba David Wheeler and Roger Needham at the Computer */ /* Laboratory of Cambridge University */ /* More info: http://www.simonshepherd.supanet.com/tea.htm */ /* */ /* TEA_decipher - decryption procedure */ /* uses global variables */ /* */ /* Source ported to Keil C51 by Marko Pavlin */ /********************************************************************/ void TEA_decipher(void) { unsigned long int sum=_SUM, delta=_DELTA; unsigned char n = _ITER; while(n-->0) { v1 -= (v0 << 4)+k2 ^ v0+sum ^ (v0 >> 5)+k3; v0 -= (v1 << 4)+k0 ^ v1+sum ^ (v1 >> 5)+k1; sum -= delta; } } /********************************************************************/ /* */ /* TEA : The Tiny Encryption Algorithm (TEA) */ /* */ /* TEA_encipher - encryption procedure */ /* uses global variables */ /* */ /********************************************************************/ void TEA_encipher(void) { unsigned long int sum=0,delta=_DELTA; unsigned char n=_ITER; while(n-->0) { sum += delta; v0 += (v1 << 4)+k0 ^ v1+sum ^ (v1 >> 5)+k1; v1 += (v0 << 4)+k2 ^ v0+sum ^ (v0 >> 5)+k3; } }
#define _DELTA 0x9E37 #define _SUM 0xC6EF
hi i saw the source code written for Tea Encryption. Sir, now i am working on a project called Automatic Frost controller for Refrigerators Using P89LPC901. Now, That i am new to this IC and the data provided in the data sheet is not sufficient can you tell me some thing about usage of this IC and Can you send me some Source Codes to configure the ports . Looking forward for your Response -Srinivas Triphase Tech