Skip to content

Instantly share code, notes, and snippets.

@andylolz
Created March 14, 2015 16:48
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 andylolz/2ff9b282a975624a62a5 to your computer and use it in GitHub Desktop.
Save andylolz/2ff9b282a975624a62a5 to your computer and use it in GitHub Desktop.
generate_url.py
#!/usr/bin/env python
import base64
import os
import sys
import webbrowser
import hashlib
import hmac
person_id = sys.argv[1]
digest = hmac.new(os.environ['MPCV_SECRET_KEY'].encode('ascii'), str(person_id).encode('ascii'), hashlib.sha512).digest()
signature_bytes = base64.urlsafe_b64encode(digest)
signature = signature_bytes.decode("ascii").rstrip("=\n")
url = "http://cv.democracyclub.org.uk/upload_cv/{person_id}/c/{secret}".format(person_id=person_id, secret=signature[0:16])
webbrowser.open(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment