Browse files

Revert to standard generation of secret keys, preventing a UnicodeDec…

…odeError. Fixes #12.
  • Loading branch information...
1 parent ff6d109 commit 1493068f90119425fee30da4727a64262b9e590e @kamalgill committed Apr 22, 2011
Showing with 6 additions and 8 deletions.
  1. +6 −8 src/application/generate_keys.py
View
14 src/application/generate_keys.py
@@ -16,22 +16,20 @@
"""
-import base64
import string
-import os
import os.path
from optparse import OptionParser
+from random import choice
from string import Template
# File settings
file_name = 'secret_keys.py'
file_template = Template('''# CSRF- and Session keys
-import base64
-CSRF_SECRET_KEY = base64.b64decode('$csrf_key')
-SESSION_KEY = base64.b64decode('$session_key')
+CSRF_SECRET_KEY = '$csrf_key'
+SESSION_KEY = '$session_key'
''')
@@ -45,9 +43,9 @@
def generate_randomkey(length):
- """Generate random key, givin a number of characters"""
- secret = os.urandom(length)
- return base64.b64encode(secret)
+ """Generate random key, given a number of characters"""
+ chars = string.letters + string.digits
+ return ''.join([choice(chars) for i in range(length)])
def write_file(contents):

0 comments on commit 1493068

Please sign in to comment.