Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
My QQ number Rust quiz
// https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=3a2c2557cb1b7d0a313c1e011ba16844
use rand::prelude::*;
fn main() {
let mut rng = SmallRng::from_seed([0x56u8; 32]);
(0..10).for_each(|_| (rng.next_u32(), ()).1);
let key: [u8; 20] = [
70, 121, 148, 150, 158, 158, 73, 14, 197, 164, 232, 30, 239, 6, 112, 10, 130, 30, 55, 173,
];
let mut bytes = [0; 20];
rng.fill_bytes(&bytes);
for b in 0..20 {
bytes[b] = key[b].wrapping_sub(bytes[b]);
}
assert_eq!(&bytes[15..], &[0; 5], "Invalid key");
let nums = &bytes[1..(bytes[0] as usize)];
println!(
"{}",
nums.iter()
.map(|n| n.to_string())
.collect::<Vec<_>>()
.join("")
);
}
@bdbai
Copy link
Author

bdbai commented Dec 5, 2021

20211128_235654000_iOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment