-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathacceptConsent.py
More file actions
executable file
·40 lines (28 loc) · 1.05 KB
/
acceptConsent.py
File metadata and controls
executable file
·40 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python
import sqlite3, cgi, cgitb
from Crypto.PublicKey import RSA
from base64 import b64decode
fOpen = open('/srv/maze/private.pem', 'r')
privateKey = fOpen.read()
rsakey = RSA.importKey(privateKey)
def decrypt(decryptThis):
raw_cipher_data = b64decode(decryptThis)
return unicode(rsakey.decrypt(raw_cipher_data))
dbName = "gameData"
db = sqlite3.connect('/srv/sqlite/data/' + dbName)
cursor = db.cursor()
# Create instance of FieldStorage
consentForm = cgi.FieldStorage()
userName = decrypt(consentForm.getvalue('userName'))
consentID = int(decrypt(consentForm.getvalue('consentID')))
dateTimeStamp = decrypt(consentForm.getvalue('dateTimeStamp'))
cursor.execute('''INSERT INTO ConsentIDData(userName, consentID, dateTimeStamp)
VALUES(?,?,?)''', (userName, consentID, dateTimeStamp))
db.commit() #changes are committed to database
db.close()
print "Content-type:text/json\r\n\r\n"
print "{",
keys = consentForm.keys()
for key in keys:
print key, ":\"", consentForm[key].value, "\"", ",",
print "}"