refactored cipher implementations