Skip to content

Instantly share code, notes, and snippets.

@bmatzelle
Last active August 29, 2015 14:11
Show Gist options
  • Save bmatzelle/3e6e34c3018d7ea24126 to your computer and use it in GitHub Desktop.
Save bmatzelle/3e6e34c3018d7ea24126 to your computer and use it in GitHub Desktop.
Python Django Vuzit signature example
import time
import sha
import hmac
import base64
# Add your client settings here
public_key = '<YOUR PUBLIC KEY>'
private_key = '<YOUR PRIVATE KEY>'
# View a document
def view_document(request):
document_id = '123abc' # You load it here
timestamp = int(time.time())
return { 'document_id': document_id
'public_key': public_key,
'timestamp': timestamp,
'signature': vuzit_signature(id) }
# Creates the signature
def vuzit_signature(document_id, timestamp):
message = 'show' + doc_id + public_key + str(timestamp)
return base64.b64encode(hmac.new(private_key, message, sha).digest())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment