Refactored existing code and added support for symmetric encryption.

Same on lines 62 and 73.