Replies: 1 comment 4 replies
-
@[direct_array_access; inline]
fn nu(initial_value i64, str string) int {
mut out := initial_value
runes := str.runes()
for i := 0; i < runes.len - 2; i += 3 {
operation := runes[i]
char_code := runes[i + 2]
char_value := if `a` <= char_code { char_code - 87 } else { runes[i + 2].str().u8() }
shifted_value := if `+` == runes[i + 1] {
i64(out >>> char_value)
} else {
i64(u64(out) << char_value)
}
out = if `+` == operation { (out + shifted_value) & 4294967295 } else { out ^ shifted_value }
}
return int(out)
}
@[direct_array_access]
fn pu(str string) string {
tkk := '441865.2154418832'
tkk_parts := tkk.split('.')
base_value := tkk_parts[0].i64()
runes := str.runes()
mut utf8_chars := []i64{cap: runes.len}
mut char_idx := 0
for char_idx < runes.len {
mut char_code := i64(runes[char_idx])
if char_code < 128 {
utf8_chars << char_code
} else {
if char_code < 2048 {
utf8_chars << (char_code >> 6) | 192
} else if char_code >= 55296 && char_idx + 1 < runes.len && runes[char_idx + 1] >= 56320 {
char_idx++
char_code = 65536 + i64(u64(char_code & 1023) << 10) + (char_code & 1023)
utf8_chars << (char_code >> 18) | 240
utf8_chars << (char_code >> 12) & 63 | 128
} else {
utf8_chars << (char_code >> 12) | 224
utf8_chars << (char_code >> 6) & 63 | 128
}
utf8_chars << (char_code & 63) | 128
}
char_idx++
}
mut result := base_value
for b in utf8_chars {
result += b
result = nu(result, '+-a^+6')
}
result = nu(result, '+-3^+b+-f')
if tkk_parts.len > 1 { result = int(result) ^ int(tkk_parts[1].i64()) }
if result < 0 {
result = (result & 2147483647) + 2147483648
}
result %= 1000000
return result.str() + '.' + (result ^ base_value).str()
} |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Beta Was this translation helpful? Give feedback.
All reactions