Igor commited on
Commit
33622bd
·
unverified ·
1 Parent(s): 558bab2

Feat: Allow Base64 input in derive command for convenience

Browse files
Files changed (1) hide show
  1. cli.py +10 -1
cli.py CHANGED
@@ -73,7 +73,16 @@ def derive(peer_shitpost, key, out):
73
  priv_key = CRYPTO.load_private_key(priv_bytes)
74
 
75
  try:
76
- peer_pub_bytes = decode_string(peer_shitpost)
 
 
 
 
 
 
 
 
 
77
  if len(peer_pub_bytes) != 32:
78
  click.echo(f"[-] Error: Decoded public key is {len(peer_pub_bytes)} bytes (expected 32).")
79
  return
 
73
  priv_key = CRYPTO.load_private_key(priv_bytes)
74
 
75
  try:
76
+ # Check if input is likely Base64 (no spaces, ends with =, correct length)
77
+ # 32 bytes b64 is 44 chars.
78
+ if " " not in peer_shitpost and peer_shitpost.endswith("=") and len(peer_shitpost) == 44:
79
+ try:
80
+ peer_pub_bytes = base64.b64decode(peer_shitpost)
81
+ except:
82
+ peer_pub_bytes = decode_string(peer_shitpost)
83
+ else:
84
+ peer_pub_bytes = decode_string(peer_shitpost)
85
+
86
  if len(peer_pub_bytes) != 32:
87
  click.echo(f"[-] Error: Decoded public key is {len(peer_pub_bytes)} bytes (expected 32).")
88
  return