1 | import time
|
---|
2 |
|
---|
3 | from array import array
|
---|
4 | from bisect import bisect_left
|
---|
5 | from pympler import asizeof
|
---|
6 |
|
---|
7 |
|
---|
8 | start = time.process_time()
|
---|
9 |
|
---|
10 | with open("/dev/shm/piotrcki-wordlist-top10m.txt") as f:
|
---|
11 | passwords = array('q', sorted({hash(x.strip()) for x in f}))
|
---|
12 |
|
---|
13 | print("Reading password list took:", time.process_time() - start)
|
---|
14 |
|
---|
15 |
|
---|
16 | start = time.process_time()
|
---|
17 |
|
---|
18 | pos = bisect_left(passwords, hash("asdfjkl:"))
|
---|
19 | is_present = pos != len(passwords) and passwords[pos] == hash("asdfjkl:")
|
---|
20 |
|
---|
21 | print("Checking if password is in list took:", time.process_time() - start)
|
---|
22 |
|
---|
23 | print("Password is in list:", is_present)
|
---|
24 |
|
---|
25 | print("Size of passwords in MB:", asizeof.asizeof(passwords) / 1024**2)
|
---|