RS2:317:Client:Login Handshake

From RuneWiki
Login handshake
Sent when a player presses "Login."
Opcode 14
Type Fixed
Length 1

This is the start to a connection between a client and server. The client initiates by sending this packet to the server and expects a response containing the response code, as well as the server's ISAAC key.

Incoming Packet Structure

Data Type Purpose Summary
Byte World selection Derived from a username's base-37 representation. This is the lowest significant byte of that operation.

Hashing Example

fn encode_base37(value: &String) -> u64 {
    let mut l = 0u64;
    for i in 0..value.len() {
        if i >= 12 {
        let c = value.as_bytes()[i] as char;
        l *= 37;

        if c >= 'A' && c <= 'Z' {
            l += (1 + c as u64) - 65;
        } else if c >= 'a' && c <= 'z' {
            l += (1 + c as u64) - 97;
        } else if c >= '0' && c <= '9' {
            l += (27 + c as u64) - 48;


let username: u64 = encode_base37(String::from("Example"));
let usernameHash: u32 = (username.wrapping_shr(16) & 31) as u32;
// at this point, usernameHash is converted to u8 and sent in a packet to the server.

Outgoing Packet Structure

Data Type Purpose Summary
QWord Obfuscation and security These first 8 bytes are ignored by the client.
Byte Response The client expects 0 to be returned here to proceed normally. This is the same response type that is used by the next stage.
QWord ISAAC seed This is the initial ISAAC seed that the client will use to encrypt and decrypt opcodes with.

These 17 bytes will tell the client whether it should proceed to exchange login information.