Last active
August 29, 2015 14:11
-
-
Save bmatzelle/3e6e34c3018d7ea24126 to your computer and use it in GitHub Desktop.
Python Django Vuzit signature example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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