⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tea.c

📁 TEA加密算法(一个非常短小的加密算法)
💻 C
字号:
/*The Tiny Encryption Algorithm, or TEA, is a Feistel cipher invented by DavidWheeler. It is intended for use in applications where code size is at apremium, or where it is necessary for someone to remember the algorithm andcode it on an arbitrary machine at a later time.Since its round function is relatively weak, with nonlinearity coming only fromthe carry propagation, TEA has 64 rounds. However, its simplicity means that itruns more quickly in software than many other algorithms with fewer, morecomplex, rounds.*/void code(long* v, long* k){unsigned long y=v[0],z=v[1],sum=0,             /* set up */              delta=0x9e3779b9, n=32 ;         /* key schedule constant*/while (n-->0){                                              /* basic cycle start*/  sum += delta ;  y += (z<<4)+k[0] ^ z+sum ^ (z>>5)+k[1] ;  z += (y<<4)+k[2] ^ y+sum ^ (y>>5)+k[3] ;     /* end cycle */}v[0]=y ;v[1]=z ;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -