Encryption

Adds James' changes for encryption.