Files
benilla-octo/crates/benilla-protocol/examples/make_account.rs
T
SamandClaude Fable 5 2ad0043523 benilla: initial public release
A from-scratch World of Warcraft 1.12.1 client in Rust + Bevy.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 14:27:01 +07:00

36 lines
1.2 KiB
Rust

//! Dev helper: print SQL to create a vmangos account, computing the SRP6 verifier/salt with
//! `benilla-srp`. vmangos stores `v`/`s` as big-endian hex, while we compute
//! little-endian, so we reverse. Usage:
//!
//! ```text
//! cargo run -p benilla-protocol --example make_account -- <user> <pass> \
//! | docker exec -i <db-container> mariadb -uroot -ppassword realmd
//! ```
use benilla_srp::NormalizedString;
fn big_endian_hex(little_endian_bytes: &[u8]) -> String {
little_endian_bytes
.iter()
.rev()
.map(|b| format!("{b:02X}"))
.collect()
}
fn main() {
let args: Vec<String> = std::env::args().collect();
let user = args.get(1).expect("usage: make_account <user> <pass>");
let pass = args.get(2).expect("usage: make_account <user> <pass>");
let username = NormalizedString::new(user).expect("invalid username");
let password = NormalizedString::new(pass).expect("invalid password");
let (salt, verifier) = benilla_srp::generate_account(&username, &password);
println!(
"INSERT INTO account (username, v, s, gmlevel, expansion) VALUES ('{}', '{}', '{}', 3, 0);",
user.to_uppercase(),
big_endian_hex(&verifier),
big_endian_hex(&salt),
);
}