Refactored existing code and added support for symmetric encryption.

It shall be filled in later.