Skip to content

Instantly share code, notes, and snippets.

@maxtaco
Forked from adamldoyle/gist:9611324
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxtaco/9611978 to your computer and use it in GitHub Desktop.
Save maxtaco/9611978 to your computer and use it in GitHub Desktop.
import base64
import binascii
import hashlib
import hmac
import requests
import scrypt
import binascii
def hex2bin(hex):
return binascii.unhexlify(hex)
logN = 15
r = 8
p = 1
name = 'name'
password = 'password'
salt_response = requests.get('https://keybase.io/_/api/1.0/getsalt.json', params={'email_or_username': name}).json()
salt = salt_response['salt']
csrf_token = salt_response['csrf_token']
login_session = salt_response['login_session']
start = 192
end = start + 32
pwh = scrypt.hash(password, hex2bin(salt), 1 << logN, r, p, end)[start:end]
hmac_pwh = hmac.new(pwh, base64.b64decode(login_session), hashlib.sha512).hexdigest()
login_response = requests.post('https://keybase.io/_/api/1.0/login.json', params={'email_or_username': name, 'csrf_token': csrf_token, 'hmac_pwh': hmac_pwh, 'login_session': login_session})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment