Refactor cipher encrypt API.