FRDU:PrincipalIdToFriendCode: Difference between revisions

From 3dbrew
Jump to navigation Jump to search
IReir (talk | contribs)
Created page with "=Request= {| class="wikitable" border="1" |- ! Index Word ! Description |- | 0 | Header code [0x00240040] |- | 1 | principalId |} This function takes the principalId given..."
 
TimmSkiller (talk | contribs)
No edit summary
 
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
|}

Latest revision as of 18:49, 14 December 2024

Request

Index Word Description
0
Header 0x00240040 Cmd 0x0024 Param 1 Xlat 0
1 Principal ID

Response

Index Word Description
0
Header 0x002400C0 Cmd 0x0024 Param 3 Xlat 0
1 Result code
2-3 u64, Friend code

Description

Converts the given Principal ID to a Friend Code. The following algorithm is used (note: everything is in little endian):

principal_id_buf = principal_id as LE bytes

friend_code = ((sha1(principal_id_buf)[0] >> 1) << 32) | principal_id