<<<
static inline uint32_t rotl(uint32_t a, uint8_t n)
{
return (a << n) | (a >> (32 - n));
}
static inline uint32_t rotr(uint32_t a, uint8_t n)
{
return (a >> n) | (a << (32 - n));
}
static inline uint32_t f1(uint32_t t){
static uint32_t tab[256] = {
0x0, 0x5010404, 0xa020808, 0xf030c0c, 0x14041010, 0x11051414, 0x1e061818, 0x1b071c1c, 0x28082020, 0x2d092424, 0x220a2828, 0x270b2c2c, 0x3c0c3030, 0x390d3434, 0x360e3838, 0x330f3c3c, 0x50104040, 0x55114444, 0x5a124848, 0x5f134c4c, 0x44145050, 0x41155454, 0x4e165858, 0x4b175c5c, 0x78186060, 0x7d196464, 0x721a6868, 0x771b6c6c, 0x6c1c7070, 0x691d7474, 0x661e7878, 0x631f7c7c, 0xa0208080, 0xa5218484, 0xaa228888, 0xaf238c8c, 0xb4249090, 0xb1259494, 0xbe269898, 0xbb279c9c, 0x8828a0a0, 0x8d29a4a4, 0x822aa8a8, 0x872bacac, 0x9c2cb0b0, 0x992db4b4, 0x962eb8b8, 0x932fbcbc, 0xf030c0c0, 0xf531c4c4, 0xfa32c8c8, 0xff33cccc, 0xe434d0d0, 0xe135d4d4, 0xee36d8d8, 0xeb37dcdc, 0xd838e0e0, 0xdd39e4e4, 0xd23ae8e8, 0xd73becec, 0xcc3cf0f0, 0xc93df4f4, 0xc63ef8f8, 0xc33ffcfc, 0x40410101, 0x45400505, 0x4a430909, 0x4f420d0d, 0x54451111, 0x51441515, 0x5e471919, 0x5b461d1d, 0x68492121, 0x6d482525, 0x624b2929, 0x674a2d2d, 0x7c4d3131, 0x794c3535, 0x764f3939, 0x734e3d3d, 0x10514141, 0x15504545, 0x1a534949, 0x1f524d4d, 0x4555151, 0x1545555, 0xe575959, 0xb565d5d, 0x38596161, 0x3d586565, 0x325b6969, 0x375a6d6d, 0x2c5d7171, 0x295c7575, 0x265f7979, 0x235e7d7d, 0xe0618181, 0xe5608585, 0xea638989, 0xef628d8d, 0xf4659191, 0xf1649595, 0xfe679999, 0xfb669d9d, 0xc869a1a1, 0xcd68a5a5, 0xc26ba9a9, 0xc76aadad, 0xdc6db1b1, 0xd96cb5b5, 0xd66fb9b9, 0xd36ebdbd, 0xb071c1c1, 0xb570c5c5, 0xba73c9c9, 0xbf72cdcd, 0xa475d1d1, 0xa174d5d5, 0xae77d9d9, 0xab76dddd, 0x9879e1e1, 0x9d78e5e5, 0x927be9e9, 0x977aeded, 0x8c7df1f1, 0x897cf5f5, 0x867ff9f9, 0x837efdfd, 0x80820202, 0x85830606, 0x8a800a0a, 0x8f810e0e, 0x94861212, 0x91871616, 0x9e841a1a, 0x9b851e1e, 0xa88a2222, 0xad8b2626, 0xa2882a2a, 0xa7892e2e, 0xbc8e3232, 0xb98f3636, 0xb68c3a3a, 0xb38d3e3e, 0xd0924242, 0xd5934646, 0xda904a4a, 0xdf914e4e, 0xc4965252, 0xc1975656, 0xce945a5a, 0xcb955e5e, 0xf89a6262, 0xfd9b6666, 0xf2986a6a, 0xf7996e6e, 0xec9e7272, 0xe99f7676, 0xe69c7a7a, 0xe39d7e7e, 0x20a28282, 0x25a38686, 0x2aa08a8a, 0x2fa18e8e, 0x34a69292, 0x31a79696, 0x3ea49a9a, 0x3ba59e9e, 0x8aaa2a2, 0xdaba6a6, 0x2a8aaaa, 0x7a9aeae, 0x1caeb2b2, 0x19afb6b6, 0x16acbaba, 0x13adbebe, 0x70b2c2c2, 0x75b3c6c6, 0x7ab0caca, 0x7fb1cece, 0x64b6d2d2, 0x61b7d6d6, 0x6eb4dada, 0x6bb5dede, 0x58bae2e2, 0x5dbbe6e6, 0x52b8eaea, 0x57b9eeee, 0x4cbef2f2, 0x49bff6f6, 0x46bcfafa, 0x43bdfefe, 0xc0c30303, 0xc5c20707, 0xcac10b0b, 0xcfc00f0f, 0xd4c71313, 0xd1c61717, 0xdec51b1b, 0xdbc41f1f, 0xe8cb2323, 0xedca2727, 0xe2c92b2b, 0xe7c82f2f, 0xfccf3333, 0xf9ce3737, 0xf6cd3b3b, 0xf3cc3f3f, 0x90d34343, 0x95d24747, 0x9ad14b4b, 0x9fd04f4f, 0x84d75353, 0x81d65757, 0x8ed55b5b, 0x8bd45f5f, 0xb8db6363, 0xbdda6767, 0xb2d96b6b, 0xb7d86f6f, 0xacdf7373, 0xa9de7777, 0xa6dd7b7b, 0xa3dc7f7f, 0x60e38383, 0x65e28787, 0x6ae18b8b, 0x6fe08f8f, 0x74e79393, 0x71e69797, 0x7ee59b9b, 0x7be49f9f, 0x48eba3a3, 0x4deaa7a7, 0x42e9abab, 0x47e8afaf, 0x5cefb3b3, 0x59eeb7b7, 0x56edbbbb, 0x53ecbfbf, 0x30f3c3c3, 0x35f2c7c7, 0x3af1cbcb, 0x3ff0cfcf, 0x24f7d3d3, 0x21f6d7d7, 0x2ef5dbdb, 0x2bf4dfdf, 0x18fbe3e3, 0x1dfae7e7, 0x12f9ebeb, 0x17f8efef, 0xcfff3f3, 0x9fef7f7, 0x6fdfbfb, 0x3fcffff
};
auto h0 = tab[(uint8_t)(t >> 24)] ;
auto h1 = rotr(tab[(uint8_t)(t >> 16)], 8);
auto h2 = rotr(tab[(uint8_t)(t >> 8)], 16);
auto h3 = rotr((tab[(uint8_t)t]), 24);
return h0 ^ h1 ^ h2 ^ h3;
}
static inline uint32_t f2(uint32_t t){
auto ea = rotl(t, 2) ^ rotl(t, 10) ^ rotl(t, 18) ;
auto eb = rotl(t, 0) ^ rotl(t, 8) ^ rotl(t, 16) ;
auto ec = rotl(eb, 2);
uint32_t ee = rotl(t, 2) ^ rotl(t, 10) ^ rotl(t, 18) ^ rotl(t, 24);
return t ^ rotl(t, 2) ^ rotl(t, 10) ^ rotl(t, 18) ^ rotl(t, 24);
}
int main(int argc, char *argv[])
{
uint32_t b = 0x00010203;
auto a1 = f1(b);
auto a2 = f2(b);
return 0;
}
#include "stdio.h"
int main(int argc, char *argv[])
{
for (uint32_t b = 0x01234541, i=0; i<567; b++,i++ ){
auto a2 = f2(b);
auto a1 = f4(b);
if (a1 != a2){
printf("error %lu\n",b);
}
}
// for (uint32_t i=0; i<256; ++i){
// auto a2 = f2(i);
// auto a3 = rotr(a2, 8);
// printf("0x%x,\t", a3);
// }
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理