Crate bl4

Crate bl4 

Source
Expand description

§bl4

Borderlands 4 save editor library - encryption, decryption, and parsing.

This library provides functionality to:

  • Decrypt and encrypt Borderlands 4 .sav files
  • Parse decrypted YAML save data
  • Decode item serials (weapons, equipment, etc.)
  • Modify save data (level, currency, inventory, etc.)

§Example

use std::fs;

let encrypted = fs::read("1.sav")?;
let steam_id = "76561197960521364";

// Decrypt and parse save file
let yaml_data = bl4::decrypt_sav(&encrypted, steam_id)?;
let mut save = bl4::SaveFile::from_yaml(&yaml_data)?;

// Query and modify save data
println!("Character: {:?}", save.get_character_name());
println!("Cash: {:?}", save.get_cash());

save.set_cash(999999)?;
save.set_character_name("NewName")?;

// Re-encrypt and save
let modified_yaml = save.to_yaml()?;
let encrypted = bl4::encrypt_sav(&modified_yaml, steam_id)?;
fs::write("1.sav", encrypted)?;

Modules§

backup
Smart backup management with hash tracking.
crypto
Borderlands 4 save file encryption and decryption
manifest
Manifest data for Borderlands 4 items
parts
Parts lookup for Borderlands 4 items
reference
Reference data for Borderlands 4 items
save
Save file parsing, querying, and modification.
serial
Item serial number decoding for Borderlands 4

Structs§

ChangeSet
Represents a set of changes to apply to a save file
ElementType
Element type information
GearType
Gear type information
ItemSerial
Decoded item serial information
LegendaryItem
Known legendary item
Manufacturer
Manufacturer information
RarityTier
Rarity tier information
SaveFile
Represents a loaded save file with query/modify capabilities
SerialFormat
Serial format configuration
StateFlags
State flags bitmask helper for inventory items.
WeaponType
Weapon type information

Enums§

BackupError
CryptoError
Errors that can occur during encryption/decryption
SaveError
SerialError
Errors that can occur during serial decoding

Constants§

ELEMENT_TYPES
All element types
GEAR_TYPES
All gear types
KNOWN_LEGENDARIES
Known legendary items
MANUFACTURERS
All manufacturers
RARITY_TIERS
All rarity tiers in order
WEAPON_TYPES
All weapon types

Functions§

all_categories
Get all category IDs and names
all_manufacturers
Get all manufacturer codes and names
category_name
category_name_for_type
Get category name with item type awareness For r-type (shields), uses shield-specific category map to avoid conflicts with weapons
decrypt_sav
Decrypt a .sav file to YAML bytes
derive_key
Derive an AES-256 key from a Steam ID
element_by_code
Get element by code
encrypt_sav
Encrypt YAML bytes to a .sav file
gear_type_by_code
Get gear type by code
item_type_name
Get a human-readable description for a type character
legendary_by_name
Find legendary by display name
level_from_code
Decode level from token (level code)
manifest_stats
Get statistics about loaded manifest data
manufacturer_by_code
Get manufacturer by code
manufacturer_name
manufacturer_name_by_code
Get manufacturer name by code (convenience function)
part_name
Get a part name by category and index
rarity_by_code
Get rarity tier by code
rarity_by_tier
Get rarity tier by tier number
serial_format
Get the serial format for a type character
serial_id_to_parts_category
Convert serial ID (first varint) to parts database category
smart_backup
Perform smart backup if needed
stat_description
Get stat description by name
update_after_edit
Update metadata after editing a save file
weapon_type_by_code
Get weapon type by code