forked from FOSS/Steam-Panel
v 3.0.3
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import base64
|
||||
|
||||
import rsa
|
||||
|
||||
|
||||
def get_rsa_key(response_data: dict) -> tuple[str, str, int]:
|
||||
"""Extract RSA key components from Steam's getrsakey response."""
|
||||
mod = response_data["publickey_mod"]
|
||||
exp = response_data["publickey_exp"]
|
||||
timestamp = int(response_data["timestamp"])
|
||||
return mod, exp, timestamp
|
||||
|
||||
|
||||
def encrypt_password(password: str, mod_hex: str, exp_hex: str) -> str:
|
||||
"""RSA-encrypt a password using Steam's public key, return base64."""
|
||||
mod = int(mod_hex, 16)
|
||||
exp = int(exp_hex, 16)
|
||||
public_key = rsa.PublicKey(mod, exp)
|
||||
encrypted = rsa.encrypt(password.encode("ascii"), public_key)
|
||||
return base64.b64encode(encrypted).decode("ascii")
|
||||
Reference in New Issue
Block a user