Line 1:
Line 1:
=Request=
=Request=
−
{| class="wikitable" border="1"
+
{{IPC/Request}}
−
|-
+
{{IPC/RequestHeader|0x0024|1|0}}
−
! Index Word
+
{{IPC/RequestEntry|Principal ID}}
−
! Description
+
{{IPC/RequestEnd}}
−
|-
−
| 0
−
| Header code [0x00240040]
−
|-
−
| 1
−
| principalId
−
|}
−
This function takes the principalId given and applies SHA-1 over it (byte order: little endian). The first byte of the SHA-1 digest is then shifted right by 1, which forms the checksum byte.
+
=Response=
+
{{IPC/Request}}
+
{{#vardefine:ipc_offset|0}}
+
{{IPC/RequestHeader|0x0024|3|0}}
+
{{IPC/RequestEntry|Result code}}
+
{{IPC/RequestEntryRange|2|u64, Friend code}}
+
{{IPC/RequestEnd}}
−
It returns an u64. The lower word is the principalId, the upper word is the checksum byte.
+
=Description=
+
Converts the given Principal ID to a Friend Code. The following algorithm is used (note: everything is in little endian):
−
=Response=
+
<code>
−
{| class="wikitable" border="1"
+
principal_id_buf = principal_id as LE bytes
−
|-
+
−
! Index Word
+
friend_code = ((sha1(principal_id_buf)[0] >> 1) << 32) | principal_id
−
! Description
+
</code>
−
|-
−
| 0
−
| Header code
−
|-
−
| 1
−
| Result code
−
|-
−
| 2-3
−
| (u64)the shareable friend code
−
|}