Moved encryption to connectas and connectto