暴力破解字典中固定长度密码的位置计算方法及示例
Got it, let's break down exactly how to find where your password sits in that 8-character dictionary starting from 00000000. First, we need to lock down a few key details that make this calculation work.
Key Prerequisite: Character Set Order
The order of characters in your dictionary is make-or-break here—different orderings will give totally different positions. For this example, we'll use the standard alphanumeric order used in most brute-force dictionaries:
- Digits first:
0→ index 0,1→ index 1, ...,9→ index 9 - Lowercase letters next:
a→ index 10,b→ index 11, ...,z→ index 35
If your dictionary uses a different order (like letters first), just adjust the character-to-index mapping— the formula structure stays identical.
Core Formula
This problem is exactly like converting a base-36 number to a decimal number, with a small tweak if you want 1-based instead of 0-based positioning.
Let your 8-character password be [c1, c2, c3, c4, c5, c6, c7, c8] (where c1 is the leftmost character, c8 is the rightmost):
- Map each character
cito its index valueviusing the mapping above - Calculate the 0-based position (where
00000000is position 0):position_0 = v1*(36^7) + v2*(36^6) + v3*(36^5) + v4*(36^4) + v5*(36^3) + v6*(36^2) + v7*(36^1) + v8*(36^0) - If you want the 1-based position (where
00000000is the 1st entry), just add 1:position_1 = position_0 + 1
Example Calculation for cocoso12
Let's walk through the example step by step:
Step 1: Map each character to its index
| Character | Index (vi) | Reason |
|---|---|---|
| c | 12 | a=10, b=11, so c=12 |
| o | 24 | a=10, o is the 15th letter → 10+14=24 |
| c | 12 | Same as above |
| o | 24 | Same as above |
| s | 28 | a=10, s is the 19th letter →10+18=28 |
| o | 24 | Same as above |
| 1 | 1 | Direct digit mapping |
| 2 | 2 | Direct digit mapping |
Step 2: Calculate each term
Compute each part of the formula:
v1*36^7 = 12 * 78364164096 = 940369969152v2*36^6 =24 * 2176782336 = 52242776064v3*36^5=12 * 60466176 = 725594112v4*36^4=24 * 1679616 = 40310784v5*36^3=28 * 46656 = 1306368v6*36^2=24 * 1296 = 31104v7*36^1=1 *36=36v8*36^0=2*1=2
Step3: Sum all terms for position_0
Adding these up gives:940369969152 + 52242776064 + 725594112 + 40310784 + 1306368 + 31104 +36 +2 = 993379987622
So:
- 0-based position of
cocoso12:993379987622 - 1-based position (if you count
00000000as the first entry):993379987623
Quick Notes
- If your dictionary uses a different character order (e.g., letters before digits), update the index mapping accordingly. For example, if
a=0,z=25,0=26, thencwould be index 2 instead of 12, which would change the final position. - The exponent values make sense because each leftmost character represents a larger block of passwords: the first character has 36^7 possible combinations for the remaining 7 positions, hence multiplying by 36^7.
内容的提问来源于stack exchange,提问作者Robert

