although impractical.
************************************************/
//#include "xtea.h"
void encipher(unsigned long *const v,unsigned long *const w, const unsigned long *const k)
{
register unsigned long y=v[0],z=v[1],sum=0,delta=0x9E3779B9,n=32;
{y+= (z<<4 ^ z>>5) + z ^ sum + k[sum&3]; sum += delta;
z+= (y<<4 ^ y>>5) + y ^ sum + k[sum>>11 & 3];
}
w[0]=y; w[1]=z;
}
void decipher(unsigned long *const v,unsigned long *const w, const unsigned long *const k)
{
register | unsigned long | y=v[0],z=v[1],sum=0xC6EF3720, |
|
| delta=0x9E3779B9,n=32; |
/* sum = | delta<<5, in general sum = delta * n */ | |
| ||
{ |
|
|
} |
|
w[0]=y; w[1]=z; |
|
- 35 - |
}
2.The TEA.H
#ifndef __XTEA_H__ #define __XTEA_H__
void encipher(unsigned long *const v,unsigned long *const w, const unsigned long *const k);
void decipher(unsigned long *const v,unsigned long *const w, const unsigned long *const k);
#endif
- 36 - |