Switched location of encrypt and decrypt functions