steam-friend-code 0.1.0

Encode and decode Steam CS:GO/CS2 friend codes and short Steam quick-invite codes.
Documentation
steam-friend-code-0.1.0 has been yanked.

steam-friend-code

Steam friend code utilities — encoding and decoding both CS:GO/CS2 in-game friend codes and short Steam quick-invite codes.

Two Code Formats

CSGO Friend Code

Base32/MD5-encoded codes used in the CS:GO and CS2 in-game friend system, displayed as ABCDE-FGHJK-LMNPQ.

use steam_friend_code::CsgoFriendCode;

// Encode a SteamID64 into a CS:GO friend code
let code = CsgoFriendCode::encode(76561198000000000)?;
println!("{}", code); // e.g. "ABCDE-FGHJK-LMNPQ"

// Decode a code back to SteamID64
let steam_id = CsgoFriendCode::decode("ABCDE-FGHJK-LMNPQ")?;

SteamFriendCode is a backward-compatible type alias for CsgoFriendCode.

Short Steam Friend Code

Hex-mapped codes used in Steam quick-invite links (https://s.team/p/{code}/{token}).

use steam_friend_code::{
    create_short_steam_friend_code,
    parse_short_steam_friend_code,
    parse_quick_invite_link,
    SHORT_STEAM_FRIEND_CODE_CHARS,
};

// Create a short code from a SteamID64
let code = create_short_steam_friend_code(76561198000000000);

// Parse a short code back to SteamID64
let steam_id = parse_short_steam_friend_code(&code)?;

// Extract SteamID64 from a full s.team/p/... URL
let steam_id = parse_quick_invite_link("https://s.team/p/abcd-efgh/TOKEN")?;

SHORT_STEAM_FRIEND_CODE_CHARS is the character alphabet used by the short code encoding.

API

Symbol Description
CsgoFriendCode Encode/decode CS:GO friend codes
SteamFriendCode Alias for CsgoFriendCode
create_short_steam_friend_code Encode SteamID64 → short invite code
parse_short_steam_friend_code Decode short invite code → SteamID64
parse_quick_invite_link Extract SteamID64 from an s.team/p/… URL
SHORT_STEAM_FRIEND_CODE_CHARS Character alphabet for short codes