remove all default keys (#1485)

This change:
- Generates a new BitTorrent pepper by default
- Generates a new pagination key by default
- Changes the pagination key format to base64
- Removes selfsigned JWT certs
- Moves test keys to test/data
This commit is contained in:
Jimmy Zelinskie 2016-05-23 16:00:48 -04:00
parent 20dcb2053e
commit 5568cc77b8
7 changed files with 15 additions and 8 deletions

View file

@ -4,12 +4,12 @@ from cryptography.fernet import Fernet, InvalidToken
def encrypt_string(string, key):
""" Encrypts a string with the specified key. The key must be 32 raw bytes. """
f = Fernet(base64.urlsafe_b64encode(key))
f = Fernet(key)
return f.encrypt(string)
def decrypt_string(string, key, ttl=None):
""" Decrypts an encrypted string with the specified key. The key must be 32 raw bytes. """
f = Fernet(base64.urlsafe_b64encode(key))
f = Fernet(key)
try:
return f.decrypt(str(string), ttl=ttl)
except InvalidToken: