HashMap
HashDoS1 ๊ณต๊ฒฉ์ผ๋ก๋ถํฐ ๋ณดํธ๋๋ ํ์ค ํด์ ๋งต์ ๋๋ค.
Standard hash map with protection against HashDoS attacks:
use std::collections::HashMap; fn main() { let mut page_counts = HashMap::new(); page_counts.insert("Adventures of Huckleberry Finn".to_string(), 207); page_counts.insert("Grimms' Fairy Tales".to_string(), 751); page_counts.insert("Pride and Prejudice".to_string(), 303); if !page_counts.contains_key("Les Misรฉrables") { println!("We've know about {} books, but not Les Misรฉrables.", page_counts.len()); } for book in ["Pride and Prejudice", "Alice's Adventure in Wonderland"] { match page_counts.get(book) { Some(count) => println!("{book}: {count} pages"), None => println!("{book} is unknown.") } } }
์ญ์ฃผ
1
Hash table์ ์ฌ์ฉํ๋ ์น์๋ฒ์ ํ๋ผ๋ฏธํฐ๊ฐ ๋ง์ POST๋ฅผ ํธ์ถํ์ฌ Hash table ์ถฉ๋์ ์ ๋ํ์ฌ CPU ๋ถํ๋ฅผ ๋ฐ์์ํค๋ ๊ณต๊ฒฉ ๋ฐฉ๋ฒ.
- POST, GET ์์ฒญ์ ํ๋ผ๋ฉํฐ์ ๋น ๋ฅธ ์ ๊ทผ์ ์ํด ์น์๋ฒ๋ ํ๋ผ๋ฉํฐ๋ฅผ Hash table๋ก ๊ด๋ฆฌํ๋๋ฐ, POST ์์ฒญ์ ์ ๋ฌํ ์ ์๋ ํ๋ผ๋ฉํฐ์ ์์ ์ ํ์ด ์๋ค๋ ์ ์ ์ด์ฉํ ๊ณต๊ฒฉ ๋ฐฉ๋ฒ