From 4ebe5aada9e1410d641e809accc88662d9832378 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Thu, 29 Feb 2024 21:55:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=88=E5=AD=98=E4=B8=80=E4=BB=BD=E8=83=BD?= =?UTF-8?q?=E8=B7=91=E7=9A=84=EF=BC=88panic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/name.rs | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/src/name.rs b/src/name.rs index 2a37f24..3c1667a 100644 --- a/src/name.rs +++ b/src/name.rs @@ -138,7 +138,6 @@ impl Namer { } bytes }; - // // 计算 // for i in 0..256 { // s += team_bytes[i % (team_len + 1)] as u32 + val[i] as u32; @@ -148,6 +147,15 @@ impl Namer { // val[s as usize] = tmp; // } // s = 0; + /* + for (int _ = 0; _ < 2; _++) { + for (int i = s = 0, j = 0; i < N; i++, j++) { + s += name[j]; + s += val[i]; + std::swap(val[i], val[s]); + if (j == len) j = -1; + } + } */ let mut s = 0_u32; for _ in 0..2 { for j in 0..256 { @@ -159,6 +167,40 @@ impl Namer { } s = 0; } + // for i in 0..256 { + // let m = ((val[i] as u32 * 181) + 160) % 256; + // if m >= 89 && m < 217 { + // name_base[s as usize] = (m & 63) as u8; + // s += 1; + // } + // } + // for _ in 0..2 { + // for i in 0..256 { + // if i < name_len { + // s = s.overflowing_add(name_bytes[i]).0; + // } + // s = s.overflowing_add(val[i]).0; + // val.swap(i, s as usize); + // } + // } + /* + #define median(x, y, z) std::max(std::min(x, y), std::min(std::max(x, y), z)) + #define LIM 96 + #define WK(x) val[i + x] = val[i + x] * 181 + 160; + #define a name_base + for (int i = 0; i < LIM; i += 8) { + WK(0) WK(1) WK(2) WK(3) WK(4) WK(5) WK(6) WK(7) + } + for (int i = 0; i < LIM && q_len < 30; i++) + if (val[i] >= 89 && val[i] < 217) a[++q_len] = val[i] & 63; + + if (q_len < 30) { + for (int i = LIM; i < N; i += 8) { + WK(0) WK(1) WK(2) WK(3) WK(4) WK(5) WK(6) WK(7) + } + for (int i = LIM; i < N && q_len < 30; i++) + if (val[i] >= 89 && val[i] < 217) a[++q_len] = val[i] & 63; + }*/ s = 0; for i in 0..256 { let m = ((val[i] as u32 * 181) + 160) % 256; @@ -167,6 +209,47 @@ impl Namer { s += 1; } } + // let mut q_len = 0; + // for i in (0..256).step_by(8) { + // val[i] = ((val[i] as u32 * 181 + 160) % 256) as u8; + // val[i+1] = ((val[i+1] as u32 * 181 + 160) % 256) as u8; + // val[i+2] = ((val[i+2] as u32 * 181 + 160) % 256) as u8; + // val[i+3] = ((val[i+3] as u32 * 181 + 160) % 256) as u8; + // val[i+4] = ((val[i+4] as u32 * 181 + 160) % 256) as u8; + // val[i+5] = ((val[i+5] as u32 * 181 + 160) % 256) as u8; + // val[i+6] = ((val[i+6] as u32 * 181 + 160) % 256) as u8; + // val[i+7] = ((val[i+7] as u32 * 181 + 160) % 256) as u8; + // } + // for i in 0..256 { + // if val[i] >= 89 && val[i] < 217 { + // name_base[q_len] = (val[i] & 63) as u8; + // q_len += 1; + // if q_len >= 30 { + // break; + // } + // } + // } + // if q_len < 30 { + // for i in (96..256).step_by(8) { + // val[i] = ((val[i] as u32 * 181 + 160) % 256) as u8; + // val[i+1] = ((val[i+1] as u32 * 181 + 160) % 256) as u8; + // val[i+2] = ((val[i+2] as u32 * 181 + 160) % 256) as u8; + // val[i+3] = ((val[i+3] as u32 * 181 + 160) % 256) as u8; + // val[i+4] = ((val[i+4] as u32 * 181 + 160) % 256) as u8; + // val[i+5] = ((val[i+5] as u32 * 181 + 160) % 256) as u8; + // val[i+6] = ((val[i+6] as u32 * 181 + 160) % 256) as u8; + // val[i+7] = ((val[i+7] as u32 * 181 + 160) % 256) as u8; + // } + // for i in 96..256 { + // if val[i] >= 89 && val[i] < 217 { + // name_base[q_len] = (val[i] & 63) as u8; + // q_len += 1; + // if q_len >= 30 { + // break; + // } + // } + // } + // } // 计算 name_prop let mut prop_cnt = 0;