Pokémon Mystery Dungeon – Passwords   Leave a comment

For tools to generate passwords, see the Wonder Mail Generator
and the SOS Mail to A-OK Mail Converter..

Wonder Mail Passwords

This page will try to explain in detail how the game decodes a Wonder Mail password.

To begin, the process rearranges the position of each character of the password by using a lookup table. The character at the old position of the password is moved to a new position. For example, the character at position 11 (starting from zero) is moved to position 14 (starting from zero) in the new password.

Old Pos. New Pos.
0 12
1 20
2 9
3 17
4 4
5 15
6 1
7 23
8 3
9 7
10 19
11 14
12 0
13 5
14 21
15 6
16 8
17 18
18 11
19 2
20 10
21 13
22 22
23 16

Then, each character of the password is converted to a 5-bit number:

Character Number
! 26
♂ (m) 30
♀ (f) 27
+ 10
- 22
11
0 9
1 24
2 25
3 28
4 16
5 17
6 1
7 2
8 6
9 7
? 0
C 19
F 8
H 20
J 21
K 23
M 18
N 3
P 4
Q 29
R 5
S 12
T 13
W 31
X 14
Y 15

In a process called bit packing, where bits are packed into 8-bit bytes
without waste of space, the password is converted into 15 binary bytes.

To understand the process further, we will give an example.

Suppose we are packing the three-character password 2FT. The process is
to convert each character to a number and then pack each number into a single
mass. To make the bit packing clearer, we will show the binary representation
of each number. (In a binary representation, each digit stands for one bit.)

Character Number Binary
2 25 11001
F 8 01000
T 13 01101

Each number is packed by starting with the rightmost bit of the number
and storing that bit on the rightmost position of the result. Then the next
rightmost bit is retrieved and stored, and so on until all bits are stored.
If there is no room to fit more bits, the next byte of the result is used.

After the bit packing process, any remaining bits of the last result byte
are filled with zeros to make the byte 8 bits long.

In this case here is how the result would look when packed this way.

Character Number Binary Result
2 25 11001 11001 (1 byte)
F 8 01000 00011001 (1 byte, no room to store integer)
F 8 01000 00011001 | 01 (2 bytes, remaining bits are stored in next byte)
T 25 01101 00011001 | 0110101 (2 bytes)
00011001 | 00110101 (2 bytes, remaining bits are filled with zeros)

In the same way, the 24-character password is converted into a 15-byte password.
(The 24 characters make up 120 bits, and the 15 bytes also make up 120 bits.)

Then from the packed password, the game calculates the password’s checksum.
The pseudocode below calculates the checksum (the code assumes that, for example,
the first byte of the password is at position 0):

sum=0                              // set the sum to 0
PasswordLength=15                  // the password is 15 bytes long
for(i=1;i

The checksum is compared with the first byte of the password. If they
match, then the password is valid.

Next, the first byte of the password is removed, making the password 14 bytes long.
(The first byte is merely a checksum, as already mentioned above.)

As a final step, the password is converted into a Wonder Mail by unpacking the bits of the
14-byte password. Bit unpacking is the reverse of bit packing. This process can be better
understood with another example.

Suppose we are unpacking bits from the two-byte sequence {45, 226}. These two bytes
are represented in binary as {00101101, 11100010}. Bit unpacking starts with the rightmost bit of the
first byte. That bit is retrieved and stored in the rightmost position of the result.
Then the next rightmost bit is retrieved and stored, and so on until all bits are stored.
If a bit can’t be retrieved or stored in the source or the result, then the next byte of the source
or result is used.

Here are the results of a sample bit unpack using the two bytes shown above.

Bits to Unpack Bits in Sequence Result
4 00101101 | 11100010 1101
3 00101101 | 11100010 010
3 00101101 | 11100010 100*
5 00101101 | 11100010 11000

* Top bit of 1st byte, bottom 2 bits of 2nd byte.

The bits of the password are stored in different positions in the Wonder Mail. Here is
the order in which the bits are unpacked and stored in the Wonder Mail.

Position Bits to Unpack Description
0 4 Mail type, must equal 5 for Wonder Mail
1 3 Mission type
2 4 Unknown, usually equal to 0
12 9 Client Pokémon (2 bytes)
14 9 Target Pokémon (2 bytes)
16 8 Item to find/deliver, safe to set to 9 if not applicable
17 4 Reward type
18 8 Item reward, safe to set to 9 if not applicable
19 6 Friend Area reward, safe to set to 0 if not applicable
8 24 3 bytes with unknown purpose, safe to set each to 255
4 7 Dungeon
5 7 Floor (for example set to 2 for 2nd floor)

Mission types:

  • 0: Help me
  • 1: Find someone
  • 2: Escort
  • 3: Find item
  • 4: Deliver item

Reward Types:

  • 0: money
  • 1: money + ?
  • 2: item
  • 3: item + ?
  • 5: money
  • 6: money + ?
  • 7: item
  • 8: item + ?
  • 9: friend area

SOS and A-OK Mail Passwords

These types of passwords have a very similar decoding process to the one for
Wonder Mail passwords. Some differences are explained here. Each SOS and A-OK Mail
password is 54 characters long. The table below
shows the positions that the characters are rearranged to:

Old Pos. New Pos.
0 23
1 16
2 37
3 45
4 4
5 41
6 52
7 1
8 8
9 39
10 25
11 36
12 47
13 0
14 12
15 3
16 33
17 20
18 28
19 9
20 49
21 53
22 51
23 31
24 11
25 2
26 13
27 14
28 34
29 5
30 46
31 27
32 17
33 18
34 19
35 29
36 38
37 48
38 22
39 32
40 42
41 15
42 6
43 26
44 30
45 10
46 44
47 50
48 35
49 7
50 40
51 21
52 43
53 24

Then the 54-character password is packed into a 34-byte password as described above.
(The 54 characters make up 270 bits, and the 34 bytes make up 272 bits, so the last 2
unused bits are filled with zeros, as described above.)

Then the checksum is calculated for the password and compared with the password’s
first byte, as described above.

Next, the first byte of the password is removed, making the password 33 bytes long.

Finally, the bits are unpacked to make an SOS or A-OK Mail, in the order shown below.

Position Bits to Unpack Description
0 4 Mail type, must equal 1 for SOS Mail, 4 for A-OK Mail, and 5 for Thank-You Mail
4 7 Dungeon
5 7 Floor (for example set to 2 for 2nd floor)
8 24 Unknown (3 bytes)
12 9 Pokémon to be rescued (2 bytes)
16 32 Mail ID (4 bytes)
20 80 Pokémon’s nickname (10 bytes), 0 marks end of name if shorter than 10 bytes
32 8 Unknown, safe to set to 1 (if Thank-You Mail) or 0
33 8 Reward item, safe to set to 0 if not Thank-You Mail
34 8 Unknown, safe to set to 0
36 32 ID of rescue team seeking help (4 bytes)
40 32 ID of rescue team giving help (4 bytes); for SOS Mail, this is 0;
for A-OK Mail, safe to set to rescue team seeking help
44 8 Rescue chances left; when converting to A-OK Mail, subtract 1 from this
45 1 Unknown, safe to set to 0

Example of Bit Packing and Checksum Calculation

Bit packing result for a 24-character password.

Character Number Binary
4 16 10000
10000
X 14 01110
11010000 | 01
0 9 01001
11010000 | 0100101
4 16 10000
11010000 | 00100101 | 1000
N 3 00011
11010000 | 00100101 | 00111000 | 0
? 0 00000
11010000 | 00100101 | 00111000 | 000000
7 2 00010
11010000 | 00100101 | 00111000 | 10000000 | 000
P 4 00100
11010000 | 00100101 | 00111000 | 10000000 | 00100000
6 1 00001
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 00001
J 21 10101
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 10
P 4 00100
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 0010010
? 0 00000
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 0000
1 24 11000
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
1
? 0 00000
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
000001
3 28 11100
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 111
# 30 11110
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111
W 31 11111
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111
9 7 00111
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 00
4 16 10000
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 1000000
? 0 00000
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 0000
? 0 00000
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 0
? 0 00000
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 000000
? 0 00000
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 00000000 | 000
? 0 00000
11010000 | 00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 00000000 | 00000000

15-byte password result:

208 | 37 | 56 | 128 | 32 | 161 | 18 | 128
1 | 247 | 255 | 64 | 0 | 0 | 0

Now the checksum is calculated. The checksum begins at 0. The first byte of
the password (208) is ignored in the calculation.

Position Byte Byte + Position Sum = Sum + Byte
+ Position
Sum = Sum AND 255
1 37 38 38 38
2 56 58 96 96
3 128 131 227 227
4 32 36 263 7
5 161 166 173 173
6 18 24 197 197
7 128 135 332 76
8 1 9 85 85
9 247 256 341 85
10 255 265 350 94
11 64 75 169 169
12 0 12 181 181
13 0 13 194 194
14 0 14 208 208

The resulting checksum is 208, which matches the first byte of the password (208).

The first byte of the password is removed in the last step, which is unpacking the bits.

Position Bits to Unpack Binary Bytes Description
0 4 0101 5 Mail type, must equal 5 for Wonder Mail
00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 00000000 | 00000000
1 3 010 2 Mission type
00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 00000000 | 00000000
2 4 0000 0 Unknown, usually equal to 0
00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 00000000 | 00000000
12 9 00000111 | 0 7 | 0 Client Pokémon (2 bytes, little endian)
00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 00000000 | 00000000
14 9 00001000 | 0 8 | 0 Target Pokémon (2 bytes, little endian)
00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 00000000 | 00000000
16 8 00001001 9 Item to find/deliver
00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 00000000 | 00000000
17 4 0101 5 Reward type
00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 00000000 | 00000000
18 8 00001001 9 Item reward
00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 00000000 | 00000000
19 6 000000 0 Friend Area reward
00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 00000000 | 00000000
8 24 00000011 | 11101110 | 11111111 3 | 238 | 255 3 bytes with unknown purpose
00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 00000000 | 00000000
4 7 0000001 1 Dungeon
00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 00000000 | 00000000
5 7 0000001 1 Floor (for example set to 2 for 2nd floor)
00100101 | 00111000 | 10000000 | 00100000 | 10100001 | 00010010 | 10000000
00000001 | 11110111 | 11111111 | 01000000 | 00000000 | 00000000 | 00000000

Posted November 24, 2014 by admin

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>